qat-cvsevents Mailing List for QAT Distributed Test Harness
Brought to you by:
webhiker
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(15) |
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Web H. <web...@us...> - 2006-04-07 20:47:09
|
Update of /cvsroot/qat/QAT/src/qat/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21211/src/qat/gui Modified Files: QAT.java Log Message: Index: QAT.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/QAT.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** QAT.java 20 Oct 2003 10:23:39 -0000 1.16 --- QAT.java 7 Apr 2006 20:47:03 -0000 1.17 *************** *** 1889,1891 **** } } ! } --- 1889,1891 ---- } } ! } |
From: Web H. <web...@us...> - 2006-04-07 20:47:09
|
Update of /cvsroot/qat/QAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21211 Modified Files: project.xml Log Message: Index: project.xml =================================================================== RCS file: /cvsroot/qat/QAT/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** project.xml 18 Jul 2005 11:42:23 -0000 1.1 --- project.xml 7 Apr 2006 20:47:03 -0000 1.2 *************** *** 61,65 **** <contributor> <name>Web Hiker</name> - <id>webhiker</id> <email>web...@us...</email> <organization>Sourceforge</organization> --- 61,64 ---- |
From: Web H. <web...@us...> - 2005-07-18 11:42:36
|
Update of /cvsroot/qat/QAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12000 Added Files: project.properties project.xml Log Message: Added Maven build files. For the moment,use only the Ant ones. --- NEW FILE: project.properties --- ############################################################ # The following properties may be modified either here, or # over-ridden build.properties in your user home directory ############################################################ maven.jar.manifest.classpath.add=true maven.jar.mainclass=QAT ############################################################ # General workspace configuration ############################################################ maven.compile.source=1.4 maven.compile.target=1.4 maven.compile.deprecation=true maven.compile.optimize=true ############################################################ --- NEW FILE: project.xml --- <?xml version="1.0" encoding="UTF-8"?> <project> <pomVersion>3</pomVersion> <name>qat</name> <groupId>qat</groupId> <id>qat</id> <currentVersion>2.7.3</currentVersion> <organization> <name>qat</name> <url>http://sourceforge.net/projects/qat/</url> <logo>http://images.sourceforge.net/images/mk2a_notour.gif</logo> </organization> <inceptionYear>2005</inceptionYear> <package>qat</package> <logo>http://images.sourceforge.net/images/head_bg_new2.gif</logo> <description>Distributed test harness for testing of non-homogenous architectures. Distribute your tests on any combination of agent architectures. Agents available in Java or native C++ if no JVM exists for your target platform (e.g. embedded architectures)</description> <shortDescription>Quality Assurance Test Harness</shortDescription> <url>http://sourceforge.net/projects/qat/</url> <issueTrackingUrl>http://sourceforge.net/tracker/?group_id=28766</issueTrackingUrl> <siteAddress>qat.sourceforge.net</siteAddress> <siteDirectory>/home/groups/q/qa/qat/htdocs/</siteDirectory> <!-- this is for specifying where distributions are deployed --> <distributionSite>qat.sourceforge.net</distributionSite> <distributionDirectory>/home/groups/q/qa/qat/htdocs/maven</distributionDirectory> <!-- the version control repository and http url for online access the connection element has the form: scm:<system>:<system specific connection string> To create the password, execute : maven -Dpassword=XXXXXXXX changelog:create-cvspass --> <repository> <connection>scm:cvs:ext:web...@cv...:/cvsroot/qat:qat</connection> <url>http://cvs.sourceforge.net/viewcvs.py/qat</url> </repository> <!-- who the developers are for the project --> <developers> <developer> <name>Web Hiker</name> <id>webhiker</id> <email>web...@us...</email> <organization>Sourceforge</organization> <roles> <role>Project Architect</role> </roles> <url>http://sourceforge.net/users/webhiker/</url> <timezone>+1</timezone> </developer> </developers> <!-- who the contributors are for the project --> <contributors> <contributor> <name>Web Hiker</name> <id>webhiker</id> <email>web...@us...</email> <organization>Sourceforge</organization> <roles> <role>Project Developer</role> </roles> <url>http://sourceforge.net/users/webhiker/</url> <timezone>+1</timezone> </contributor> </contributors> <licenses> <license> <name>GNU General Public License (GPL)</name> <url>http://sourceforge.net/softwaremap/trove_list.php?form_cat=15</url> <distribution>manual</distribution> </license> </licenses> <!-- external libs required to build this project --> <dependencies> <dependency> <artifactId>jlfgr</artifactId> <groupId>jlfgr</groupId> <version>1-0</version> <properties> <jar.manifest.classpath>true</jar.manifest.classpath> </properties> </dependency> <dependency> <artifactId>junit</artifactId> <groupId>junit</groupId> <url>http://junit.org</url> <version>3.8.1</version> <properties> <jar.manifest.classpath>true</jar.manifest.classpath> </properties> </dependency> </dependencies> <!-- build information for the project --> <build> <nagEmailAddress>web...@us...</nagEmailAddress> <sourceDirectory>src</sourceDirectory> <unitTestSourceDirectory>src/test</unitTestSourceDirectory> <unitTest> <includes> <include>**/*Test.java</include> </includes> <excludes> <exclude>**/NaughtyTest.java</exclude> </excludes> </unitTest> <resources> <resource> <targetPath>resources</targetPath> <directory>src/resources</directory> <includes> <include>*.properties</include> <include>*.png</include> </includes> </resource> <!-- <resource> <directory>external/jlfgr</directory> <includes> <include>*.jar</include> </includes> </resource> <resource> <directory>external/junit3.8.1</directory> <includes> <include>*.jar</include> </includes> </resource> --> </resources> </build> <reports> <report>maven-junit-report-plugin</report> <report>maven-jdepend-plugin</report> <report>maven-checkstyle-plugin</report> <report>maven-pmd-plugin</report> <report>maven-developer-activity-plugin</report> <report>maven-license-plugin</report> <report>maven-javadoc-plugin</report> <report>maven-jxr-plugin</report> <report>maven-tasklist-plugin</report> <report>maven-changelog-plugin</report> </reports> </project> |
From: Web H. <web...@us...> - 2005-07-18 11:42:36
|
Update of /cvsroot/qat/QAT/src/qat/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12000/src/qat/gui Modified Files: HttpWorker.java Log Message: Added Maven build files. For the moment,use only the Ant ones. Index: HttpWorker.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/HttpWorker.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HttpWorker.java 11 Feb 2002 15:42:38 -0000 1.2 --- HttpWorker.java 18 Jul 2005 11:42:23 -0000 1.3 *************** *** 32,885 **** public class HttpWorker extends HttpQATHandler { ! final static int BUF_SIZE = 2048; ! final static String pageBgCol = "#CCCCCC"; ! final static String fontCol = "#FFFFFF"; ! final static String commandTableCol = "#EEFFE6"; // Run All, Run Passed etc.... ! final static String agentTableCol = "#ADEEDD"; // table with defined agents ! final static String agentTableTitleCol = "#FFCCCC"; // title of table for defined agents ! final static String loadProjectTableCol = "#FFE6FF"; ! final static String testOutputTableTitleCol = "#FFCCCC"; // the titles for the table containg test traces [...1680 lines suppressed...] ! writeLn(ps,"<br>"); ! } ! private void writeHr(PrintStream ps) throws IOException { ! writeLn(ps,"<hr>"); ! } ! private void writeLn(PrintStream ps, String s) throws IOException { ! ps.print(s); ! ps.write(EOL); ! } ! private ArrayList arrayToArrayList(Object obj[]) { ! ArrayList res = new ArrayList(obj.length); ! for (int i = 0; i < obj.length; i++) ! res.add(obj[i]); ! return res; ! } } |
From: Web H. <web...@us...> - 2005-07-18 11:42:36
|
Update of /cvsroot/qat/QAT/src/qat/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12000/src/qat/common Modified Files: Resources.java Log Message: Added Maven build files. For the moment,use only the Ant ones. Index: Resources.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/common/Resources.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Resources.java 11 Feb 2002 15:42:38 -0000 1.2 --- Resources.java 18 Jul 2005 11:42:23 -0000 1.3 *************** *** 11,84 **** public class Resources { ! private static ResourceBundle resources; static { ! resources = loadBundle("resources.QAT"); } ! public static ResourceBundle loadBundle(String bundle) { ! try { ! return ResourceBundle.getBundle(bundle, Locale.getDefault()); ! } ! catch (MissingResourceException mre) { ! mre.printStackTrace(); ! System.err.println(mre.toString()); ! //System.exit(1); ! } ! return null; } ! public static String getString(String s) { ! try { ! return resources.getString(s); ! } ! catch (MissingResourceException e) { ! System.out.println("Error: No resources defined for "+s); ! return null; ! } } ! public static URL getResource(Class c, String name) { ! try { ! return c.getResource(name); ! } ! catch (MissingResourceException e) { ! //System.out.println("Error: No resources defined for "+name); ! return null; ! } } ! public static URL getResource(String name) { ! try { ! return getResource(Class.forName("QAT"),name); ! } ! catch (ClassNotFoundException e) { ! //System.out.println("Class not defined !!!"); ! return null; ! } ! catch (MissingResourceException e) { ! //System.out.println("Error: No resources defined for "+name); ! return null; ! } } ! /** ! * Returns the URL for an image to be loaded out ! * of the jar file. ! */ ! public static URL getImageResource(String key) { ! try { ! String name = Resources.getString(key); ! if (name != null) { ! return Resources.getResource(name); ! } ! else { ! return null; ! } ! } ! catch (Exception e) { ! System.out.println(e.toString()); ! return null; ! } } } --- 11,84 ---- public class Resources { ! private static ResourceBundle resources; static { ! resources = loadBundle("resources.QAT"); } ! public static ResourceBundle loadBundle(String bundle) { ! try { ! return ResourceBundle.getBundle(bundle, Locale.getDefault()); ! } ! catch (MissingResourceException mre) { ! mre.printStackTrace(); ! System.err.println(mre.toString()); ! //System.exit(1); } + return null; + } ! public static String getString(String s) { ! try { ! return resources.getString(s); } + catch (MissingResourceException e) { + System.out.println("Error: No resources defined for "+s); + return null; + } + } ! public static URL getResource(Class c, String name) { ! try { ! return c.getResource(name); } + catch (MissingResourceException e) { + //System.out.println("Error: No resources defined for "+name); + return null; + } + } ! public static URL getResource(String name) { ! try { ! return getResource(Class.forName("QAT"),name); } + catch (ClassNotFoundException e) { + //System.out.println("Class not defined !!!"); + return null; + } + catch (MissingResourceException e) { + //System.out.println("Error: No resources defined for "+name); + return null; + } + } ! /** ! * Returns the URL for an image to be loaded out ! * of the jar file. ! */ ! public static URL getImageResource(String key) { ! try { ! String name = Resources.getString(key); ! if (name != null) { ! return Resources.getResource(name); ! } ! else { ! return null; ! } } + catch (Exception e) { + System.out.println(e.toString()); + return null; + } + } } |
From: Web H. <web...@us...> - 2005-05-30 10:29:42
|
Update of /cvsroot/qat/QAT/src/qat/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22335/src/qat/gui Modified Files: TestSpecification.java TestTree.java Log Message: Sort the selected test nodes so they can be run alphabetically. Index: TestSpecification.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/TestSpecification.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestSpecification.java 25 Nov 2002 11:40:00 -0000 1.4 --- TestSpecification.java 30 May 2005 10:29:32 -0000 1.5 *************** *** 20,23 **** --- 20,24 ---- import java.util.Properties; import java.lang.Runtime; + import java.lang.Comparable; import java.lang.reflect.Constructor; import javax.swing.JComponent; *************** *** 29,33 **** import qat.parser.ParserInterface; ! public class TestSpecification extends Object { private static final short testName = 0; private static final short testAuthor = 1; --- 30,34 ---- import qat.parser.ParserInterface; ! public class TestSpecification extends Object implements Comparable { private static final short testName = 0; private static final short testAuthor = 1; *************** *** 396,398 **** --- 397,403 ---- out.writeObject(propertyValue[testBugInfo]); } + + public int compareTo(Object o) { + return toString().compareTo(o.toString()); + } } Index: TestTree.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/TestTree.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestTree.java 27 May 2003 11:37:15 -0000 1.5 --- TestTree.java 30 May 2005 10:29:32 -0000 1.6 *************** *** 534,537 **** --- 534,538 ---- resultList.add(result); } + java.util.Collections.sort(result); return resultList; } *************** *** 549,552 **** --- 550,554 ---- result.add(node); } + java.util.Collections.sort(result); return result; } *************** *** 564,567 **** --- 566,570 ---- result.add(node.getUserObject()); } + java.util.Collections.sort(result); return result; } *************** *** 585,588 **** --- 588,592 ---- result.add(node); } + java.util.Collections.sort(result); return result; } |
From: AmH <sl...@us...> - 2004-06-02 16:22:34
|
Update of /cvsroot/qat/QAT/src/qat/agent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27856 Modified Files: ExecProcess.java Log Message: Set working directory of process to agent's QAT working directory. Index: ExecProcess.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/agent/ExecProcess.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExecProcess.java 27 Nov 2002 11:17:46 -0000 1.5 --- ExecProcess.java 2 Jun 2004 16:22:25 -0000 1.6 *************** *** 90,93 **** --- 90,95 ---- String commandArgs[] = test.getExecuteCommand(); + File workDir = new File(test.getWorkDirectory()); + // build the environment string list from our TestObject properties String environment[] = new String[test.getExecuteEnvironment().size()]; *************** *** 118,121 **** --- 120,124 ---- for (int i = 0; i < environment.length; i++) debugMsg(environment[i],out,1); + debugMsg("Working directory : " + workDir,out,1); debugMsg("",out,1); *************** *** 124,128 **** environment = null; ! setProcess(Runtime.getRuntime().exec(commandArgs, environment)); // only store traces if it's not a daemon process --- 127,131 ---- environment = null; ! setProcess(Runtime.getRuntime().exec(commandArgs, environment, workDir)); // only store traces if it's not a daemon process |
From: AmH <sl...@us...> - 2004-06-02 16:07:07
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25267 Modified Files: QAXMLParser.java Log Message: (1) added support for 'random' node, (2) added filePath variable to help with keeping track of base file name when parsing include files, (3) processNode: added check for interrupt in node processing loop (not sure this is complete), (4) processPropertyNode: resolve property names before creating/setting the property, (5) processPropertyNode: added 'verbose' tag to disable the onlyif print out, (6) other code cleanup. Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** QAXMLParser.java 2 Jun 2004 15:46:14 -0000 1.8 --- QAXMLParser.java 2 Jun 2004 16:06:52 -0000 1.9 *************** *** 50,61 **** private static final int INCLUDE_NODE = 16; private static final int REPORT_NODE = 17; ! private static final int COMMENT_NODE = 18; ! private static final int TEXT_NODE = 19; ! private static final int IGNORE_NODE = 20; private static final String keywords[] = {"qaxml","test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", ! "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; --- 50,62 ---- private static final int INCLUDE_NODE = 16; private static final int REPORT_NODE = 17; ! private static final int RANDOM_NODE = 18; ! private static final int COMMENT_NODE = 19; ! private static final int TEXT_NODE = 20; ! private static final int IGNORE_NODE = 21; private static final String keywords[] = {"qaxml","test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", ! "report", "random", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; *************** *** 65,68 **** --- 66,70 ---- private boolean interrupted = false; private String testPath; + private String filePath; private java.util.HashMap agentMap; private int statusCode = ProtocolConstants.PASSED; *************** *** 70,73 **** --- 72,77 ---- private List qaxmlIncludeList, propertiesIncludeList; + private static Random randomVar = new Random(); + private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once *************** *** 86,89 **** --- 90,95 ---- public QAXMLParser(QAXMLParser parser) { this(); + setTestPath(parser.getTestPath()); + prepare(parser.getProjectResultsDir()); setStatusLabel(parser.getStatusLabel()); setProperties(parser.getProperties()); *************** *** 108,116 **** /** ! * This method sets the path to file file containing the syntax ! * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } --- 114,141 ---- /** ! * This method sets the path to file containing the <test> syntax ! * to be parsed, it does not change when parsing include files. */ public void setTestPath(String testPath) { this.testPath = testPath; + setFilePath(testPath); + } + + /** + * This method gets the path to file containing the <test> syntax + * to be parsed. + */ + private String getTestPath() { + return this.testPath; + } + + /** + * This method sets the path for the file currently being parsed. This + * path differs from testPath in that this is set to the value of an + * include file while parsing the include file. Therefore, filePath + * changes for each include file, while testPath does not. + */ + public void setFilePath(String filePath) { + this.filePath = filePath; } *************** *** 173,180 **** */ public int parseFile() throws Exception { ! org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; ! properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); --- 198,205 ---- */ public int parseFile() throws Exception { ! org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(filePath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; ! properties.setProperty("qaxml.basedir",new File(filePath).getParentFile().getCanonicalPath()); processNode(root); *************** *** 254,257 **** --- 279,285 ---- processReportNode(node); break; + case RANDOM_NODE : + processRandomNode(node); + break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); *************** *** 262,269 **** // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); ! while(child != null) { processNode(child); child = child.getNextSibling(); } } --- 290,303 ---- // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); ! while((child != null) && (!isInterrupted())) { processNode(child); child = child.getNextSibling(); } + + if (isInterrupted()) { + //if (!isStatusReported()) { + setStatus(ProtocolConstants.UNRESOLVED); + //} + } } *************** *** 372,376 **** e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> ! which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { --- 406,419 ---- e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> ! which will first resolve the variable references, and then set the property.<br><br> ! Variable references can also be used to form the 'name' value, for example:<br> ! <code><pre> ! <loop name="i" start="1" end="${qat.agent.count}" inc="1"> ! <property name="mypropertyname${i}" value="mypropertyvalue"/> ! <property name="myotherproperty${i}" refid="${someotherproperty}"/> ! </loop> ! </pre></code> ! The above code would create a two properties, one named 'mypropertyname1' and ! the other named 'myotherproperty2'. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { *************** *** 378,389 **** try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); ! properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } ! else { ! printStream.println("property "+getAttribute(attributes,"name")+" ignored (onlyif false)"); } } --- 421,436 ---- try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); + StringBuffer name = getAttribute(attributes,"name"); + name = resolveVariable(getAttribute(attributes,"name", "")); + if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); ! ! properties.setProperty(name.toString(),value.toString()); } ! else if (verbose(attributes)) { ! printStream.println("property "+name+" ignored (onlyif false)"); } } *************** *** 693,697 **** } catch (Exception e) { ! printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } --- 740,744 ---- } catch (Exception e) { ! printError(CLEANZIP_NODE,"invalid cleanzip node ("+e.toString()+")"); } } *************** *** 806,812 **** if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); ! StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); ! processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); ! printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) --- 853,862 ---- if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); ! StringBuffer processid = resolveVariable(processidname); ! processidname = QAXMLExpression.removeVariableBraces(processidname); ! processidname = resolveVariable(processidname); ! setStatusText(traceNode.getNodeName()+" "+processidname.toString()); ! printStream.println(traceNode.getNodeName()+" "+processidname.toString()); ! AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) *************** *** 850,854 **** } catch (Exception e) { ! printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } --- 900,904 ---- } catch (Exception e) { ! printError(CLEAN_NODE,"invalid clean node ("+e.toString()+")"); } } *************** *** 861,868 **** */ public void processIncludeNode(org.w3c.dom.Node includeNode) { try { org.w3c.dom.NamedNodeMap attributes = includeNode.getAttributes(); if (onlyIf(attributes)) { ! StringBuffer fileName = resolveVariable(getAttribute(attributes,"filename")); // check if it exists File f = new File(fileName.toString()); --- 911,919 ---- */ public void processIncludeNode(org.w3c.dom.Node includeNode) { + StringBuffer fileName = null; try { org.w3c.dom.NamedNodeMap attributes = includeNode.getAttributes(); if (onlyIf(attributes)) { ! fileName = resolveVariable(getAttribute(attributes,"filename")); // check if it exists File f = new File(fileName.toString()); *************** *** 882,886 **** printDebug("including qaxml file "+fileName.toString()); QAXMLParser childParser = new QAXMLParser(this); ! childParser.setTestPath(fileName.toString()); int includeStatus = childParser.parseFile(); Properties newProperties = childParser.getProperties(); --- 933,937 ---- printDebug("including qaxml file "+fileName.toString()); QAXMLParser childParser = new QAXMLParser(this); ! childParser.setFilePath(fileName.toString()); int includeStatus = childParser.parseFile(); Properties newProperties = childParser.getProperties(); *************** *** 898,906 **** } catch (Exception e) { ! printError(INCLUDE_NODE,"problem with include file ("+e.toString()+") "); } } /** * This tag causes a global property to be set. <report status="passed, failed"/><br> --- 949,979 ---- } catch (Exception e) { ! printError(INCLUDE_NODE,"problem with include file '"+fileName.toString()+"' ("+e.toString()+") "); } } /** + * This tag sets the designated variable to a random value. <br> + e.g. <random<br> + name="myrandomvar" // variable to set<br> + onlyif="result" /> // optional - execute only if true<br> + */ + public void processRandomNode(org.w3c.dom.Node randomNode) { + setStatusText(randomNode.getNodeName()); + try { + org.w3c.dom.NamedNodeMap attributes = randomNode.getAttributes(); + + if (onlyIf(attributes)) { + properties.setProperty(getAttribute(attributes,"name").toString(), + Integer.toString(Math.abs(randomVar.nextInt()))); + } + } + catch (Exception e) { + printError(RANDOM_NODE,"invalid random node ("+e.getMessage()+")"); + } + } + + + /** * This tag causes a global property to be set. <report status="passed, failed"/><br> *************** *** 935,939 **** } catch (Exception e) { ! printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } --- 1008,1012 ---- } catch (Exception e) { ! printError(REPORT_NODE,"invalid report node ("+e.getMessage()+")"); } } *************** *** 986,990 **** return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); ! } private boolean isInterrupted() { return interrupted; } --- 1059,1065 ---- return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); ! } ! ! private boolean isInterrupted() { return interrupted; } *************** *** 1100,1103 **** --- 1175,1187 ---- /** + * This is called when a new parser is created for parsing an 'include' + * file. The return value is passed to prepare() so that + * projectResultsDir remains consistent in the child parsers. + */ + public String getProjectResultsDir() { + return this.projectResultsDir; + } + + /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. *************** *** 1149,1155 **** printStream.print(msg); printStream.print(" in file "); ! printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); ! } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); --- 1233,1241 ---- printStream.print(msg); printStream.print(" in file "); ! printStream.print(HtmlPrintStream.RED,filePath); printStream.printBoldln(" ]"); ! } ! ! static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); *************** *** 1177,1180 **** --- 1263,1276 ---- } + public boolean verbose(org.w3c.dom.NamedNodeMap attributes) { + StringBuffer verbose = getAttribute(attributes,"verbose",TRUE); + if (verbose.toString().equals(TRUE)) { + return true; + } + else { + return false; + } + } + public int getStatus() { return this.statusCode; |
From: AmH <sl...@us...> - 2004-06-02 15:46:25
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21447 Modified Files: QAXMLParser.java Log Message: Convert line endings from Mac to Unix. Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** QAXMLParser.java 26 May 2004 13:33:13 -0000 1.7 --- QAXMLParser.java 2 Jun 2004 15:46:14 -0000 1.8 *************** *** 1 **** ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int QAXML_NODE = 0; private static final int TEST_NODE = 1; private static final int PRINTENV_NODE = 2; private static final int SLEEP_NODE = 3; private static final int PROPERTY_NODE = 4; private static final int REQUESTAGENT_NODE = 5; private static final int RELEASEAGENT_NODE = 6; private static final int CHECKAGENT_NODE = 7; private static final int LOOP_NODE = 8; private static final int ECHO_NODE = 9; private static final int SENDZIP_NODE = 10; private static final int CLEANZIP_NODE = 11; private static final int START_NODE = 12; private static final int STATUS_NODE = 13; private static final int TRACE_NODE = 14; private static final int CLEAN_NODE = 15; private static final int INCLUDE_NODE = 16; private static final int REPORT_NODE = 17; private static final int COMMENT_NODE = 18; private static final int TEXT_NODE = 19; private static final int IGNORE_NODE = 20; private static final String keywords[] = {"qaxml","test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int statusCode = ProtocolConstants.PASSED; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); setStatus(ProtocolConstants.PASSED); } /** * This method is used to clone values of an existing parser, for example * when processing an include file. */ public QAXMLParser(QAXMLParser parser) { this(); setStatusLabel(parser.getStatusLabel()); setProperties(parser.getProperties()); setEvaluationMode(parser.inEvaluationMode()); setPrintStream(parser.getPrintStream(),parser.getPrintStream() instanceof HtmlPrintStream); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public PrintStream getPrintStream() { return printStream; } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return getStatus(); } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case QAXML_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); setStatus(ProtocolConstants.UNRESOLVED); printError(-1,"Unknown node type ("+nodeType+") "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = printEnvNode.getAttributes(); if (onlyIf(attributes)) { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } else { printStream.println("printenv ignored (onlyif false)"); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); if (onlyIf(attributes)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif false)"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } else { printStream.println("property "+getAttribute(attributes,"name")+" ignored (onlyif false)"); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif false)"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); if (onlyIf(attributes)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif false)"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (onlyIf(attributes)) { if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } else { printStream.println("checkagent ignored (onlyif false)"); } } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> name="i"<br> start="0"<br> end="5"<br> inc="1"<br> echo message="The current value is ${i}"/><br> loop/><br> <br> Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processLoopNode(org.w3c.dom.Node loopNode) { try { org.w3c.dom.NamedNodeMap attributes = loopNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer name = getAttribute(attributes,"name"); StringBuffer start = resolveVariable(getAttribute(attributes,"start", "0")); StringBuffer end = resolveVariable(getAttribute(attributes,"end")); StringBuffer inc = resolveVariable(getAttribute(attributes,"inc", "1")); printStream.println(loopNode.getNodeName()+" "+name+" from "+start+" by "+inc+" until "+end); int endint = Integer.parseInt(end.toString()); int incint = Integer.parseInt(inc.toString()); for (int loop_var = Integer.parseInt(start.toString()); loop_var <= endint; loop_var+=incint) { properties.put(name.toString(),Integer.toString(loop_var)); // now iterate through child elements of root org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { processNode(children.item(i)); } } // remove the variable declaration, since it should be // visible local to the loop block only properties.remove(name.toString()); // tag all the children so they don't get processed again org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { ignoreNodes.add(children.item(i)); } } else { printStream.println("loop ignored (onlyif false)"); } } catch (Exception e) { printError(LOOP_NODE,"invalid loop node ("+loopNode.toString()+")"); } } /** * This tag allows you to echo traces to the harness.<br> e.g. <echo message="A java property is ${java.home}"/> */ public void processEchoNode(org.w3c.dom.Node echoNode) { setStatusText(echoNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = echoNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer message = resolveVariable(getAttribute(attributes,"message")); printStream.println(HtmlPrintStream.GREEN,message.toString()); } } catch (Exception e) { printError(ECHO_NODE,"invalid echo node found ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <sendzip<br> onlyif="variable" (optional, execute only if variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processSendZipNode(org.w3c.dom.Node sendzipNode) { try { org.w3c.dom.NamedNodeMap attributes = sendzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); if (onlyIf(attributes)) { setStatusText(sendzipNode.getNodeName()+" "+agentid); printStream.println(sendzipNode.getNodeName()+" "+zipfile+" to agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); // send the zip file, and retrieve the associated zip ID try { properties.setProperty(agentid.toString()+zipfile.toString(), agentInstance.ZIPSEND(zipfile.toString(),agentid.toString()+zipfile.toString())); } catch (Exception ex) { printError(SENDZIP_NODE,"problem sending zip file to agent ("+ex.toString()+")"); } } else { printStream.println("sendzip cancelled (onlyif false)"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <cleanzip<br> onlyif="variable" (optional, execute only of variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processCleanZipNode(org.w3c.dom.Node cleanzipNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); if (onlyIf(attributes)) { setStatusText(cleanzipNode.getNodeName()+" "+agentid); printStream.println(cleanzipNode.getNodeName()+" from agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); agentInstance.ZIPCLEAN(agentid.toString()+zipfile.toString()); properties.remove(agentid.toString()+zipfile.toString()); } else { printStream.println("cleanzip cancelled (onlyif false)"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <start<br> processid="variable" (the id of the process for future reference)<br> agentid="agentid" (the id of the agent you want to start the process on)<br> command="command string" (the command you want to execute)<br> arguments="argument string" (the arguments to the command)<br> timeout="timeout" (the timeout for this command)<br> onlyif="variable"/> (optional - execute only if true)<br> */ public void processStartNode(org.w3c.dom.Node startNode) { try { org.w3c.dom.NamedNodeMap attributes = startNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processid = resolveVariable(getAttribute(attributes, "processid")); StringBuffer agentid = resolveVariable(getAttribute(attributes, "agentid")); StringBuffer command = resolveVariable(getAttribute(attributes, "command")); StringBuffer arguments = resolveVariable(getAttribute(attributes, "arguments","")); StringBuffer timeout = resolveVariable(getAttribute(attributes, "timeout","0")); setStatusText(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); printStream.println(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); // check that this process id is unused if (properties.getProperty(processid.toString())!=null) { throw new Exception("processid "+processid+" already exists"); } StringTokenizer tokens = new StringTokenizer(arguments.toString()," "); String[] cmdArray = new String[1+tokens.countTokens()]; cmdArray[0] = command.toString(); int i = 1; while(tokens.hasMoreTokens()) { cmdArray[i++] = tokens.nextToken(); } AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); properties.setProperty(processid.toString(), agentInstance.CMDSTART(cmdArray, timeout.toString())); } else { printStream.println("start cancelled (onlyif false)"); } } catch (Exception e) { printError(START_NODE,"invalid start node ("+e.toString()+")"); } } /** * This task will retrieve the status of an executed process.<br> e.g. <status<br> processid="variable" (the id of the process for future reference)<br> status="result" (the status of processid will be placed in this variable)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processStatusNode(org.w3c.dom.Node statusNode) { try { org.w3c.dom.NamedNodeMap attributes = statusNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); StringBuffer result = resolveVariable(getAttribute(attributes, "status")); setStatusText(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); printStream.println(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processidname); String statusCode = agentInstance.CMDSTATUS(processid.toString()); if (Integer.parseInt(statusCode)==0) properties.setProperty(result.toString(),"passed"); else properties.setProperty(result.toString(),"failed"); // now print out a message if the status was timed out int value = Integer.parseInt(statusCode); if (value == qat.agent.ExecProcess.TIMEDOUT_STATE) { printDebug("command "+processidname+" timed out!"); } else { if (value < 0) { printDebug("command "+processidname.toString()+" failed!"); } else { printDebug("command "+processidname.toString()+" exited normally"); } } } else { printStream.println("start cancelled (onlyif false)"); } } catch (Exception e) { printError(STATUS_NODE,"invalid status node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <trace<br> processid="variable" (the processid to retrieve the trace for)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processTraceNode(org.w3c.dom.Node traceNode) { try { org.w3c.dom.NamedNodeMap attributes = traceNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processid); agentInstance.CMDGETTRACE(processid.toString(), projectResultsDir+File.separator+ Common.getUniqueTestIdentifier(testPath)+"_"+processidname.toString()); addToPropertiesList(INTERNAL_TRACE_LIST,processidname.toString()); } else { printStream.println("trace cancelled (onlyif false)"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <clean<br> processid="variable" // the processid to retrieve the trace for<br> onlyif="result"/> // optional - execute only if true<br> */ public void processCleanNode(org.w3c.dom.Node cleanNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); setStatusText(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); printStream.println(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("Unknown processID :"+processid.toString()); agentInstance.CMDCLEAN(processid.toString()); properties.remove(processidname.toString()); } else { printStream.println("trace cancelled (onlyif false)"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <include<br> filename="filename" // the file to include. May be either a QAXML file or a Java style properties file<br> onlyif="result"/> // optional - execute only if true<br> */ public void processIncludeNode(org.w3c.dom.Node includeNode) { try { org.w3c.dom.NamedNodeMap attributes = includeNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer fileName = resolveVariable(getAttribute(attributes,"filename")); // check if it exists File f = new File(fileName.toString()); if (!f.exists()) { throw new Exception("Include file not found :"+fileName); } // check if it's a .properties include or a .qinc/other type of file if (fileName.toString().toLowerCase().endsWith(Common.PROPERTIES_EXTENSION)) { printDebug("including properties file "+fileName.toString()); Properties newProperties = new Properties(); newProperties.load(new FileInputStream(fileName.toString())); properties = Utils.mergeProperties(properties,newProperties); propertiesIncludeList.add(fileName.toString()); } else { printDebug("including qaxml file "+fileName.toString()); QAXMLParser childParser = new QAXMLParser(this); childParser.setTestPath(fileName.toString()); int includeStatus = childParser.parseFile(); Properties newProperties = childParser.getProperties(); properties = Utils.mergeProperties(properties,newProperties); if (includeStatus!=ProtocolConstants.PASSED) { setStatus(includeStatus); } qaxmlIncludeList.add(fileName.toString()); } } else { printStream.println("ignoring include (onlyif false)"); } } catch (Exception e) { printError(INCLUDE_NODE,"problem with include file ("+e.toString()+") "); } } /** * This tag causes a global property to be set. <report status="passed, failed"/><br> Note, an unresolved result can not be over-ridden. */ public void processReportNode(org.w3c.dom.Node reportNode) { setStatusText(reportNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = reportNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer statusStr = resolveVariable(getAttribute(attributes,"status","failed")); setStatusText(reportNode.getNodeName()+" "+statusStr.toString()); printStream.println(reportNode.getNodeName()+" "+statusStr.toString()); // unresolved always overrides any test result if (getStatus() != ProtocolConstants.UNRESOLVED) { if (inEvaluationMode()) { setStatus(ProtocolConstants.PASSED); } else { if (statusStr.toString().toLowerCase().equals("passed")) { setStatus(ProtocolConstants.PASSED); } else { if (getTestBugInfo().equals("")) { setStatus(ProtocolConstants.FAILED); } else { setStatus(ProtocolConstants.PENDING); } } } } } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } private void addToPropertiesList(String key, String prop) { String list = properties.getProperty(key,""); prop = "\""+prop+"\""; if (list != null) { if (list.indexOf(prop)<0) properties.setProperty(key,list+" "+prop); } else { properties.setProperty(key,prop); } } /** * Looks through currently running agents for an identifier matching processID. * Returns the matching AgentInstance, or null if it wasn't found. */ private AgentInstance getAgentRunningProcess(StringBuffer processid) { try { AgentInstance agentInstance; for (Iterator e = agentMap.keySet().iterator() ; e.hasNext() ;) { agentInstance = (AgentInstance)agentMap.get(e.next()); if (agentInstance.isHandlingProcess(processid.toString())) { return agentInstance; } } } catch(Exception e) { printError(23,"no agent was running this process!"); } return null; } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName) { return getAttribute(attributes, attributeName, ""); } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName, String defaultValue) { org.w3c.dom.Node attribute = attributes.getNamedItem(attributeName); if (attribute !=null) return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); } private boolean isInterrupted() { return interrupted; } /** * This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files. */ public void interrupt() { interrupted = true; // now call kill for all active agents if (!inEvaluationMode()) { } } /** * This method retrieves the specified property from the results of parsing this file. */ public String getProperty(String key) { return "NOT YET IMPLEMENTED"; } /** * This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned. */ public String getProperty(String key, String defaultValue) { return "NOT YET IMPLEMENTED"; } /** * This method should return a test name which will be used to display the test in * the test tree. */ public String getTestName() { return name; } /** * This method should return a test Author which will be used to display the test in * the test tree. */ public String getTestAuthor() { return author; } /** * This method should return a test Description which will be used to display the test in * the test tree. */ public String getTestDescription() { return description; } /** * This method should return a test BugInfo which will be used for displaying the test in * the test tree. */ public String getTestBugInfo() { return buginfo; } /** * This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness. */ public String[] getKeyWords() { return new String[0]; } /** * This should return the list of files other than standard java.util.Properties files which were * included to parse this test file. */ public String[] getIncludeList() { String[] list = new String[qaxmlIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)qaxmlIncludeList.get(i); } return list; } /** * This should return the list of standard java.util.Properties files which were * included to parse this test file. */ public String[] getPropertiesIncludeList() { String[] list = new String[propertiesIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)propertiesIncludeList.get(i); } return list; } /** * This method should list all available output files produced by this test when run on the agent, * but relative to the harness. */ public String[] getTraceList() { return Utils.toStringArray(properties.getProperty(INTERNAL_TRACE_LIST).toString()); } /** * This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness. */ public void prepare(String projectResultsDir) { this.projectResultsDir = projectResultsDir; } /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. */ public PrintStream openPrintStream(String fileName) throws java.io.FileNotFoundException { return new HtmlPrintStream(new PrintStream(new FileOutputStream(fileName),true),true); } /* * This method centralises all the traces printed by the parser. */ public void printDebug(String msg) { } /** * This method indicates we are finished with this parser, and disposes * any reserved resources. */ public void finish() { } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public void setStatusLabel(JLabel status) { statusLabel = status; } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public JLabel getStatusLabel() { return statusLabel; } private void setStatusText(String s) { if (!inEvaluationMode()) statusLabel.setText(s); } private void printError(int code, String msg) { setStatus(ProtocolConstants.FAILED); printStream.printBold("[ "); printStream.print(HtmlPrintStream.GREEN, keywords[code]); printStream.print(HtmlPrintStream.RED," error :"); printStream.print(msg); printStream.print(" in file "); printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Throwable t) { t.printStackTrace(); } } public StringBuffer resolveVariable(StringBuffer expression) throws Exception { return QAXMLExpression.resolveVariable(expression,properties); } public boolean onlyIf(org.w3c.dom.NamedNodeMap attributes) throws Exception { StringBuffer variable = getAttribute(attributes,"onlyif",TRUE); StringBuffer onlyif = resolveVariable(variable); if (onlyif.toString().equals(TRUE)) { return true; } else { BooleanExpression expr = new BooleanExpression(onlyif); boolean result = expr.evaluate(); return result; } } public int getStatus() { return this.statusCode; } public void setStatus(int newStatus) { if (statusCode != ProtocolConstants.UNRESOLVED) { // unresolved always overrides any test result this.statusCode = newStatus; } } public static final void main(String args[]) { try { System.getProperties().setProperty("qat.agent.count","1"); System.getProperties().setProperty("agent1.name","triolet"); System.getProperties().setProperty("agent1.port","9000"); QAXMLParser parser = new QAXMLParser(); parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); parser.setProperties(System.getProperties()); parser.setPrintStream(System.out, false); parser.setEvaluationMode(true); parser.setStatusLabel(new JLabel()); parser.parseFile(); } catch (Throwable t) { t.printStackTrace(); } } } \ No newline at end of file --- 1,1207 ---- ! package qat.parser.qaxmlparser; ! ! // JDK imports ! import java.io.*; ! import java.util.*; ! import java.lang.*; ! import java.net.*; [...1180 lines suppressed...] ! ! public static final void main(String args[]) { ! try { ! System.getProperties().setProperty("qat.agent.count","1"); ! System.getProperties().setProperty("agent1.name","triolet"); ! System.getProperties().setProperty("agent1.port","9000"); ! QAXMLParser parser = new QAXMLParser(); ! parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); ! parser.setProperties(System.getProperties()); ! parser.setPrintStream(System.out, false); ! parser.setEvaluationMode(true); ! parser.setStatusLabel(new JLabel()); ! parser.parseFile(); ! } ! catch (Throwable t) { ! t.printStackTrace(); ! } ! } ! ! } |
From: AmH <sl...@us...> - 2004-06-02 15:45:17
|
Update of /cvsroot/qat/QAT/src/qat/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21019 Modified Files: TestRunner.java Log Message: Convert line endings from Mac to Unix. Index: TestRunner.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/TestRunner.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestRunner.java 3 Jun 2003 14:10:01 -0000 1.6 --- TestRunner.java 2 Jun 2004 15:44:52 -0000 1.7 *************** *** 1 **** ! package qat.gui; /** * * @author webhiker * @version 2.3, 17 June 1999 */ import java.io.File; import java.lang.Thread; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Date; import qat.parser.*; import qat.common.*; import qat.gui.*; /** * This object is resposible for running a single or multiple tests. * It is implemented as a Thread to allow interuption of a running task. * If the test run is interrupted, the currently executing test must exit before * the stop is completed. * * @author webhiker * @version %W %E */ public class TestRunner extends Thread { private boolean running, evaluationMode; private ArrayList runList; // this is a list of QAT files to be run private QAT parent; // handle on the parent so we can paint update info for tree & status private TestSpecification test; // this is the handle for each test as it is run private int runProgress; private Date startTime, endTime; private String rootDirectory; public TestRunner(QAT p) { parent = p; runList = new ArrayList(); startTime = new Date(0); endTime = new Date(0); setEvaluationMode(false); } public void setProjectRoot(String rootDirectory) { this.rootDirectory = rootDirectory; } public void run() { // check only once instance is running at a time if (running) { return; } else { running = true; } // set up the status bar, and intialize all the counters parent.setStatusGaugeMax(runList.size()); int result; // clear status of all the selected tests setStatus(runList,ProtocolConstants.NOTRUN,false); parent.updateStatus(Resources.getString("startingRun"),runList,0); startTime = new Date(); endTime = startTime; TestFinderInterface testFinder = new GenericTestFinder(parent.getProperties()); testFinder.setProjectRoot(rootDirectory); ParserInterface parser; for(int i = 0; ((i < runList.size())&&(running)); i++) { runProgress = i; test = (TestSpecification)runList.get(i); parser = testFinder.getParser(new File(test.getTestSpecPath())); if (parser==null) { System.out.println("No test finder registered for "+test.getTestSpecPath()); } else { parser.prepare(parent.getProjectResultsDirectory()); parser.setStatusLabel(parent.getParserStatusLabel()); test.clearTraceFiles(parent.getProjectResultsDirectory()); test.setStatus(ProtocolConstants.RUNNING); parent.updateTest(test,inEvaluationMode()); if (inEvaluationMode()) { parent.updateStatus(Resources.getString("startParse")+" "+test.getTestName(),1); test.parseTest(parent.getProjectResultsDirectory(), parent.getProperties(), parser); } else { parent.updateStatus(Resources.getString("running")+" "+test.getTestName(),1); test.runTest(parent.getProjectResultsDirectory(), parent.getProperties(), parser); } endTime = new Date(); parent.updateTest(test,inEvaluationMode()); parser.finish(); } } if (running) { parent.updateStatus(Resources.getString("done"),0); } else { setStatus(runList,ProtocolConstants.UNRESOLVED,true); parent.updateStatus(Resources.getString("interrupted"),0); } running = false; runList.clear(); } /** * Sets all the tests to the specified status. If interrupted is true, only tests with status=NOTRUN will * be set to this status. */ private void setStatus(ArrayList list, int status, boolean interrupted) { for(int i = 0; i < runList.size(); i++) { test = (TestSpecification)runList.get(i); if (interrupted) { if (test.getStatus()==ProtocolConstants.NOTRUN) test.setStatus(status); } else { test.setStatus(status); } } } /** * Returns the number of tests from this run which have * already completed. */ public int getRunProgress() { return runProgress+1; } /** * Returns the total number of tests selected for this run, or * returns zero if no tests are running. */ public int getRunTotal() { return runList.size(); } public boolean isRunning() { return running; } public String getRemainingTime() { int totalNoTests = getRunTotal(); int alreadyRunTests = runProgress; int testsRemaining = (totalNoTests - alreadyRunTests); if (testsRemaining<2) testsRemaining = 0; long timePerTest; if (alreadyRunTests>0) { timePerTest = (endTime.getTime()-startTime.getTime()) / alreadyRunTests; } else { timePerTest = 0; } long timeLeft = timePerTest * (testsRemaining); return getTimeString(new Date(timeLeft)); } public String getElapsedTime() { return getTimeString(new Date(endTime.getTime()-startTime.getTime())); } public static String getTimeString(Date d) { Calendar c = new GregorianCalendar(); c.setTime(d); return Integer.toString(c.get(Calendar.HOUR_OF_DAY)-1)+"h "+ Integer.toString(c.get(Calendar.MINUTE))+"m "+ Integer.toString(c.get(Calendar.SECOND))+"s"; } public void setRunList(ArrayList list) { runList = list; } public void interrupt() { running = false; if (runList!=null) runList.clear(); if (test!=null) { test.interrupt(); parent.updateTest(test,inEvaluationMode()); } } public boolean inEvaluationMode() { return evaluationMode; } public void setEvaluationMode(boolean m) { evaluationMode = m; } } \ No newline at end of file --- 1,203 ---- ! package qat.gui; ! /** ! * ! * @author webhiker ! * @version 2.3, 17 June 1999 ! */ ! import java.io.File; ! import java.lang.Thread; ! import java.util.ArrayList; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! import java.util.Date; ! ! import qat.parser.*; ! import qat.common.*; ! import qat.gui.*; ! ! /** ! * This object is resposible for running a single or multiple tests. ! * It is implemented as a Thread to allow interuption of a running task. ! * If the test run is interrupted, the currently executing test must exit before ! * the stop is completed. ! * ! * @author webhiker ! * @version %W %E ! */ ! public class TestRunner extends Thread { ! private boolean running, evaluationMode; ! private ArrayList runList; // this is a list of QAT files to be run ! private QAT parent; // handle on the parent so we can paint update info for tree & status ! private TestSpecification test; // this is the handle for each test as it is run ! private int runProgress; ! private Date startTime, endTime; ! private String rootDirectory; ! ! public TestRunner(QAT p) { ! parent = p; ! runList = new ArrayList(); ! startTime = new Date(0); ! endTime = new Date(0); ! setEvaluationMode(false); ! } ! ! public void setProjectRoot(String rootDirectory) { ! this.rootDirectory = rootDirectory; ! } ! ! public void run() { ! // check only once instance is running at a time ! if (running) { ! return; ! } ! else { ! running = true; ! } ! // set up the status bar, and intialize all the counters ! parent.setStatusGaugeMax(runList.size()); ! ! int result; ! // clear status of all the selected tests ! setStatus(runList,ProtocolConstants.NOTRUN,false); ! ! parent.updateStatus(Resources.getString("startingRun"),runList,0); ! startTime = new Date(); ! endTime = startTime; ! ! TestFinderInterface testFinder = new GenericTestFinder(parent.getProperties()); ! testFinder.setProjectRoot(rootDirectory); ! ParserInterface parser; ! ! for(int i = 0; ((i < runList.size())&&(running)); i++) { ! runProgress = i; ! test = (TestSpecification)runList.get(i); ! parser = testFinder.getParser(new File(test.getTestSpecPath())); ! if (parser==null) { ! System.out.println("No test finder registered for "+test.getTestSpecPath()); ! } ! else { ! parser.prepare(parent.getProjectResultsDirectory()); ! parser.setStatusLabel(parent.getParserStatusLabel()); ! test.clearTraceFiles(parent.getProjectResultsDirectory()); ! test.setStatus(ProtocolConstants.RUNNING); ! parent.updateTest(test,inEvaluationMode()); ! if (inEvaluationMode()) { ! parent.updateStatus(Resources.getString("startParse")+" "+test.getTestName(),1); ! test.parseTest(parent.getProjectResultsDirectory(), ! parent.getProperties(), ! parser); ! } ! else { ! parent.updateStatus(Resources.getString("running")+" "+test.getTestName(),1); ! test.runTest(parent.getProjectResultsDirectory(), ! parent.getProperties(), ! parser); ! } ! endTime = new Date(); ! parent.updateTest(test,inEvaluationMode()); ! parser.finish(); ! } ! } ! ! if (running) { ! parent.updateStatus(Resources.getString("done"),0); ! } ! else { ! setStatus(runList,ProtocolConstants.UNRESOLVED,true); ! parent.updateStatus(Resources.getString("interrupted"),0); ! } ! running = false; ! runList.clear(); ! } ! ! /** ! * Sets all the tests to the specified status. If interrupted is true, only tests with status=NOTRUN will ! * be set to this status. ! */ ! private void setStatus(ArrayList list, int status, boolean interrupted) { ! for(int i = 0; i < runList.size(); i++) { ! test = (TestSpecification)runList.get(i); ! if (interrupted) { ! if (test.getStatus()==ProtocolConstants.NOTRUN) ! test.setStatus(status); ! } ! else { ! test.setStatus(status); ! } ! } ! } ! ! /** ! * Returns the number of tests from this run which have ! * already completed. ! */ ! public int getRunProgress() { ! return runProgress+1; ! } ! ! /** ! * Returns the total number of tests selected for this run, or ! * returns zero if no tests are running. ! */ ! public int getRunTotal() { ! return runList.size(); ! } ! ! public boolean isRunning() { ! return running; ! } ! ! public String getRemainingTime() { ! int totalNoTests = getRunTotal(); ! int alreadyRunTests = runProgress; ! int testsRemaining = (totalNoTests - alreadyRunTests); ! if (testsRemaining<2) ! testsRemaining = 0; ! long timePerTest; ! if (alreadyRunTests>0) { ! timePerTest = (endTime.getTime()-startTime.getTime()) / alreadyRunTests; ! } ! else { ! timePerTest = 0; ! } ! long timeLeft = timePerTest * (testsRemaining); ! ! return getTimeString(new Date(timeLeft)); ! } ! ! public String getElapsedTime() { ! return getTimeString(new Date(endTime.getTime()-startTime.getTime())); ! } ! ! public static String getTimeString(Date d) { ! Calendar c = new GregorianCalendar(); ! c.setTime(d); ! ! ! return Integer.toString(c.get(Calendar.HOUR_OF_DAY)-1)+"h "+ ! Integer.toString(c.get(Calendar.MINUTE))+"m "+ ! Integer.toString(c.get(Calendar.SECOND))+"s"; ! } ! ! public void setRunList(ArrayList list) { ! runList = list; ! } ! ! public void interrupt() { ! running = false; ! if (runList!=null) ! runList.clear(); ! if (test!=null) { ! test.interrupt(); ! parent.updateTest(test,inEvaluationMode()); ! } ! } ! ! public boolean inEvaluationMode() { ! return evaluationMode; ! } ! ! public void setEvaluationMode(boolean m) { ! evaluationMode = m; ! } ! } |
From: Web H. <web...@us...> - 2004-05-26 13:33:25
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25460/src/qat/parser/qaxmlparser Modified Files: BooleanExpression.java QAXMLParser.java Log Message: Update QAXML onlyif statements to allow < > = and # operators, as well as fix bug when evaluating boolean expression. Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** QAXMLParser.java 14 May 2004 14:51:44 -0000 1.6 --- QAXMLParser.java 26 May 2004 13:33:13 -0000 1.7 *************** *** 1 **** ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int QAXML_NODE = 0; private static final int TEST_NODE = 1; private static final int PRINTENV_NODE = 2; private static final int SLEEP_NODE = 3; private static final int PROPERTY_NODE = 4; private static final int REQUESTAGENT_NODE = 5; private static final int RELEASEAGENT_NODE = 6; private static final int CHECKAGENT_NODE = 7; private static final int LOOP_NODE = 8; private static final int ECHO_NODE = 9; private static final int SENDZIP_NODE = 10; private static final int CLEANZIP_NODE = 11; private static final int START_NODE = 12; private static final int STATUS_NODE = 13; private static final int TRACE_NODE = 14; private static final int CLEAN_NODE = 15; private static final int INCLUDE_NODE = 16; private static final int REPORT_NODE = 17; private static final int COMMENT_NODE = 18; private static final int TEXT_NODE = 19; private static final int IGNORE_NODE = 20; private static final String keywords[] = {"qaxml","test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int statusCode = ProtocolConstants.PASSED; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); setStatus(ProtocolConstants.PASSED); } /** * This method is used to clone values of an existing parser, for example * when processing an include file. */ public QAXMLParser(QAXMLParser parser) { this(); setStatusLabel(parser.getStatusLabel()); setProperties(parser.getProperties()); setEvaluationMode(parser.inEvaluationMode()); setPrintStream(parser.getPrintStream(),parser.getPrintStream() instanceof HtmlPrintStream); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public PrintStream getPrintStream() { return printStream; } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return getStatus(); } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case QAXML_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); setStatus(ProtocolConstants.UNRESOLVED); printError(-1,"Unknown node type ("+nodeType+") "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = printEnvNode.getAttributes(); if (onlyIf(attributes)) { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } else { printStream.println("printenv ignored (onlyif false)"); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); if (onlyIf(attributes)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif false)"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } else { printStream.println("property "+getAttribute(attributes,"name")+" ignored (onlyif false)"); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif false)"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); if (onlyIf(attributes)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif false)"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (onlyIf(attributes)) { if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } else { printStream.println("checkagent ignored (onlyif false)"); } } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> name="i"<br> start="0"<br> end="5"<br> inc="1"<br> echo message="The current value is ${i}"/><br> loop/><br> <br> Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processLoopNode(org.w3c.dom.Node loopNode) { try { org.w3c.dom.NamedNodeMap attributes = loopNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer name = getAttribute(attributes,"name"); StringBuffer start = resolveVariable(getAttribute(attributes,"start", "0")); StringBuffer end = resolveVariable(getAttribute(attributes,"end")); StringBuffer inc = resolveVariable(getAttribute(attributes,"inc", "1")); printStream.println(loopNode.getNodeName()+" "+name+" from "+start+" by "+inc+" until "+end); int endint = Integer.parseInt(end.toString()); int incint = Integer.parseInt(inc.toString()); for (int loop_var = Integer.parseInt(start.toString()); loop_var <= endint; loop_var+=incint) { properties.put(name.toString(),Integer.toString(loop_var)); // now iterate through child elements of root org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { processNode(children.item(i)); } } // remove the variable declaration, since it should be // visible local to the loop block only properties.remove(name.toString()); // tag all the children so they don't get processed again org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { ignoreNodes.add(children.item(i)); } } else { printStream.println("loop ignored (onlyif false)"); } } catch (Exception e) { printError(LOOP_NODE,"invalid loop node ("+loopNode.toString()+")"); } } /** * This tag allows you to echo traces to the harness.<br> e.g. <echo message="A java property is ${java.home}"/> */ public void processEchoNode(org.w3c.dom.Node echoNode) { setStatusText(echoNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = echoNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer message = resolveVariable(getAttribute(attributes,"message")); printStream.println(HtmlPrintStream.GREEN,message.toString()); } } catch (Exception e) { printError(ECHO_NODE,"invalid echo node found ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <sendzip<br> onlyif="variable" (optional, execute only if variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processSendZipNode(org.w3c.dom.Node sendzipNode) { try { org.w3c.dom.NamedNodeMap attributes = sendzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); if (onlyIf(attributes)) { setStatusText(sendzipNode.getNodeName()+" "+agentid); printStream.println(sendzipNode.getNodeName()+" "+zipfile+" to agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); // send the zip file, and retrieve the associated zip ID try { properties.setProperty(agentid.toString()+zipfile.toString(), agentInstance.ZIPSEND(zipfile.toString(),agentid.toString()+zipfile.toString())); } catch (Exception ex) { printError(SENDZIP_NODE,"problem sending zip file to agent ("+ex.toString()+")"); } } else { printStream.println("sendzip cancelled (onlyif false)"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <cleanzip<br> onlyif="variable" (optional, execute only of variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processCleanZipNode(org.w3c.dom.Node cleanzipNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); if (onlyIf(attributes)) { setStatusText(cleanzipNode.getNodeName()+" "+agentid); printStream.println(cleanzipNode.getNodeName()+" from agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); agentInstance.ZIPCLEAN(agentid.toString()+zipfile.toString()); properties.remove(agentid.toString()+zipfile.toString()); } else { printStream.println("cleanzip cancelled (onlyif false)"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <start<br> processid="variable" (the id of the process for future reference)<br> agentid="agentid" (the id of the agent you want to start the process on)<br> command="command string" (the command you want to execute)<br> arguments="argument string" (the arguments to the command)<br> timeout="timeout" (the timeout for this command)<br> onlyif="variable"/> (optional - execute only if true)<br> */ public void processStartNode(org.w3c.dom.Node startNode) { try { org.w3c.dom.NamedNodeMap attributes = startNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processid = resolveVariable(getAttribute(attributes, "processid")); StringBuffer agentid = resolveVariable(getAttribute(attributes, "agentid")); StringBuffer command = resolveVariable(getAttribute(attributes, "command")); StringBuffer arguments = resolveVariable(getAttribute(attributes, "arguments","")); StringBuffer timeout = resolveVariable(getAttribute(attributes, "timeout","0")); setStatusText(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); printStream.println(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); // check that this process id is unused if (properties.getProperty(processid.toString())!=null) { throw new Exception("processid "+processid+" already exists"); } StringTokenizer tokens = new StringTokenizer(arguments.toString()," "); String[] cmdArray = new String[1+tokens.countTokens()]; cmdArray[0] = command.toString(); int i = 1; while(tokens.hasMoreTokens()) { cmdArray[i++] = tokens.nextToken(); } AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); properties.setProperty(processid.toString(), agentInstance.CMDSTART(cmdArray, timeout.toString())); } else { printStream.println("start cancelled (onlyif false)"); } } catch (Exception e) { printError(START_NODE,"invalid start node ("+e.toString()+")"); } } /** * This task will retrieve the status of an executed process.<br> e.g. <status<br> processid="variable" (the id of the process for future reference)<br> status="result" (the status of processid will be placed in this variable)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processStatusNode(org.w3c.dom.Node statusNode) { try { org.w3c.dom.NamedNodeMap attributes = statusNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); StringBuffer result = resolveVariable(getAttribute(attributes, "status")); setStatusText(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); printStream.println(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processidname); String statusCode = agentInstance.CMDSTATUS(processid.toString()); if (Integer.parseInt(statusCode)==0) properties.setProperty(result.toString(),"passed"); else properties.setProperty(result.toString(),"failed"); // now print out a message if the status was timed out int value = Integer.parseInt(statusCode); if (value == qat.agent.ExecProcess.TIMEDOUT_STATE) { printDebug("command "+processidname+" timed out!"); } else { if (value < 0) { printDebug("command "+processidname.toString()+" failed!"); } else { printDebug("command "+processidname.toString()+" exited normally"); } } } else { printStream.println("start cancelled (onlyif false)"); } } catch (Exception e) { printError(STATUS_NODE,"invalid status node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <trace<br> processid="variable" (the processid to retrieve the trace for)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processTraceNode(org.w3c.dom.Node traceNode) { try { org.w3c.dom.NamedNodeMap attributes = traceNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processid); agentInstance.CMDGETTRACE(processid.toString(), projectResultsDir+File.separator+ Common.getUniqueTestIdentifier(testPath)+"_"+processidname.toString()); addToPropertiesList(INTERNAL_TRACE_LIST,processidname.toString()); } else { printStream.println("trace cancelled (onlyif false)"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <clean<br> processid="variable" // the processid to retrieve the trace for<br> onlyif="result"/> // optional - execute only if true<br> */ public void processCleanNode(org.w3c.dom.Node cleanNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); setStatusText(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); printStream.println(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("Unknown processID :"+processid.toString()); agentInstance.CMDCLEAN(processid.toString()); properties.remove(processidname.toString()); } else { printStream.println("trace cancelled (onlyif false)"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <include<br> filename="filename" // the file to include. May be either a QAXML file or a Java style properties file<br> onlyif="result"/> // optional - execute only if true<br> */ public void processIncludeNode(org.w3c.dom.Node includeNode) { try { org.w3c.dom.NamedNodeMap attributes = includeNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer fileName = resolveVariable(getAttribute(attributes,"filename")); // check if it exists File f = new File(fileName.toString()); if (!f.exists()) { throw new Exception("Include file not found :"+fileName); } // check if it's a .properties include or a .qinc/other type of file if (fileName.toString().toLowerCase().endsWith(Common.PROPERTIES_EXTENSION)) { printDebug("including properties file "+fileName.toString()); Properties newProperties = new Properties(); newProperties.load(new FileInputStream(fileName.toString())); properties = Utils.mergeProperties(properties,newProperties); propertiesIncludeList.add(fileName.toString()); } else { printDebug("including qaxml file "+fileName.toString()); QAXMLParser childParser = new QAXMLParser(this); childParser.setTestPath(fileName.toString()); int includeStatus = childParser.parseFile(); Properties newProperties = childParser.getProperties(); properties = Utils.mergeProperties(properties,newProperties); if (includeStatus!=ProtocolConstants.PASSED) { setStatus(includeStatus); } qaxmlIncludeList.add(fileName.toString()); } } else { printStream.println("ignoring include (onlyif false)"); } } catch (Exception e) { printError(INCLUDE_NODE,"problem with include file ("+e.toString()+") "); } } /** * This tag causes a global property to be set. <report status="passed, failed"/><br> Note, an unresolved result can not be over-ridden. */ public void processReportNode(org.w3c.dom.Node reportNode) { setStatusText(reportNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = reportNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer statusStr = resolveVariable(getAttribute(attributes,"status","failed")); setStatusText(reportNode.getNodeName()+" "+statusStr.toString()); printStream.println(reportNode.getNodeName()+" "+statusStr.toString()); // unresolved always overrides any test result if (getStatus() != ProtocolConstants.UNRESOLVED) { if (inEvaluationMode()) { setStatus(ProtocolConstants.PASSED); } else { if (statusStr.toString().toLowerCase().equals("passed")) { setStatus(ProtocolConstants.PASSED); } else { if (getTestBugInfo().equals("")) { setStatus(ProtocolConstants.FAILED); } else { setStatus(ProtocolConstants.PENDING); } } } } } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } private void addToPropertiesList(String key, String prop) { String list = properties.getProperty(key,""); prop = "\""+prop+"\""; if (list != null) { if (list.indexOf(prop)<0) properties.setProperty(key,list+" "+prop); } else { properties.setProperty(key,prop); } } /** * Looks through currently running agents for an identifier matching processID. * Returns the matching AgentInstance, or null if it wasn't found. */ private AgentInstance getAgentRunningProcess(StringBuffer processid) { try { AgentInstance agentInstance; for (Iterator e = agentMap.keySet().iterator() ; e.hasNext() ;) { agentInstance = (AgentInstance)agentMap.get(e.next()); if (agentInstance.isHandlingProcess(processid.toString())) { return agentInstance; } } } catch(Exception e) { printError(23,"no agent was running this process!"); } return null; } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName) { return getAttribute(attributes, attributeName, ""); } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName, String defaultValue) { org.w3c.dom.Node attribute = attributes.getNamedItem(attributeName); if (attribute !=null) return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); } private boolean isInterrupted() { return interrupted; } /** * This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files. */ public void interrupt() { interrupted = true; // now call kill for all active agents if (!inEvaluationMode()) { } } /** * This method retrieves the specified property from the results of parsing this file. */ public String getProperty(String key) { return "NOT YET IMPLEMENTED"; } /** * This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned. */ public String getProperty(String key, String defaultValue) { return "NOT YET IMPLEMENTED"; } /** * This method should return a test name which will be used to display the test in * the test tree. */ public String getTestName() { return name; } /** * This method should return a test Author which will be used to display the test in * the test tree. */ public String getTestAuthor() { return author; } /** * This method should return a test Description which will be used to display the test in * the test tree. */ public String getTestDescription() { return description; } /** * This method should return a test BugInfo which will be used for displaying the test in * the test tree. */ public String getTestBugInfo() { return buginfo; } /** * This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness. */ public String[] getKeyWords() { return new String[0]; } /** * This should return the list of files other than standard java.util.Properties files which were * included to parse this test file. */ public String[] getIncludeList() { String[] list = new String[qaxmlIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)qaxmlIncludeList.get(i); } return list; } /** * This should return the list of standard java.util.Properties files which were * included to parse this test file. */ public String[] getPropertiesIncludeList() { String[] list = new String[propertiesIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)propertiesIncludeList.get(i); } return list; } /** * This method should list all available output files produced by this test when run on the agent, * but relative to the harness. */ public String[] getTraceList() { return Utils.toStringArray(properties.getProperty(INTERNAL_TRACE_LIST).toString()); } /** * This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness. */ public void prepare(String projectResultsDir) { this.projectResultsDir = projectResultsDir; } /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. */ public PrintStream openPrintStream(String fileName) throws java.io.FileNotFoundException { return new HtmlPrintStream(new PrintStream(new FileOutputStream(fileName),true),true); } /* * This method centralises all the traces printed by the parser. */ public void printDebug(String msg) { } /** * This method indicates we are finished with this parser, and disposes * any reserved resources. */ public void finish() { } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public void setStatusLabel(JLabel status) { statusLabel = status; } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public JLabel getStatusLabel() { return statusLabel; } private void setStatusText(String s) { if (!inEvaluationMode()) statusLabel.setText(s); } private void printError(int code, String msg) { setStatus(ProtocolConstants.FAILED); printStream.printBold("[ "); printStream.print(HtmlPrintStream.RED,"Error "); printStream.print("("); printStream.print(code); printStream.print(") :"); printStream.print(msg); printStream.print(" in file "); printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Throwable t) { t.printStackTrace(); } } public StringBuffer resolveVariable(StringBuffer expression) throws Exception { return QAXMLExpression.resolveVariable(expression,properties); } public boolean onlyIf(org.w3c.dom.NamedNodeMap attributes) throws Exception { StringBuffer variable = getAttribute(attributes,"onlyif",TRUE); StringBuffer onlyif = resolveVariable(variable); if (onlyif.toString().equals(TRUE)) { return true; } else { BooleanExpression expr = new BooleanExpression(onlyif); boolean result = expr.evaluate(); return result; } } public int getStatus() { return this.statusCode; } public void setStatus(int newStatus) { if (statusCode != ProtocolConstants.UNRESOLVED) { // unresolved always overrides any test result this.statusCode = newStatus; } } public static final void main(String args[]) { try { System.getProperties().setProperty("qat.agent.count","1"); System.getProperties().setProperty("agent1.name","triolet"); System.getProperties().setProperty("agent1.port","9000"); QAXMLParser parser = new QAXMLParser(); parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); parser.setProperties(System.getProperties()); parser.setPrintStream(System.out, false); parser.setEvaluationMode(true); parser.setStatusLabel(new JLabel()); parser.parseFile(); } catch (Throwable t) { t.printStackTrace(); } } } \ No newline at end of file --- 1 ---- ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int QAXML_NODE = 0; private static final int TEST_NODE = 1; private static final int PRINTENV_NODE = 2; private static final int SLEEP_NODE = 3; private static final int PROPERTY_NODE = 4; private static final int REQUESTAGENT_NODE = 5; private static final int RELEASEAGENT_NODE = 6; private static final int CHECKAGENT_NODE = 7; private static final int LOOP_NODE = 8; private static final int ECHO_NODE = 9; private static final int SENDZIP_NODE = 10; private static final int CLEANZIP_NODE = 11; private static final int START_NODE = 12; private static final int STATUS_NODE = 13; private static final int TRACE_NODE = 14; private static final int CLEAN_NODE = 15; private static final int INCLUDE_NODE = 16; private static final int REPORT_NODE = 17; private static final int COMMENT_NODE = 18; private static final int TEXT_NODE = 19; private static final int IGNORE_NODE = 20; private static final String keywords[] = {"qaxml","test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int statusCode = ProtocolConstants.PASSED; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); setStatus(ProtocolConstants.PASSED); } /** * This method is used to clone values of an existing parser, for example * when processing an include file. */ public QAXMLParser(QAXMLParser parser) { this(); setStatusLabel(parser.getStatusLabel()); setProperties(parser.getProperties()); setEvaluationMode(parser.inEvaluationMode()); setPrintStream(parser.getPrintStream(),parser.getPrintStream() instanceof HtmlPrintStream); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public PrintStream getPrintStream() { return printStream; } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return getStatus(); } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case QAXML_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); setStatus(ProtocolConstants.UNRESOLVED); printError(-1,"Unknown node type ("+nodeType+") "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = printEnvNode.getAttributes(); if (onlyIf(attributes)) { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } else { printStream.println("printenv ignored (onlyif false)"); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); if (onlyIf(attributes)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif false)"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } else { printStream.println("property "+getAttribute(attributes,"name")+" ignored (onlyif false)"); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif false)"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); if (onlyIf(attributes)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif false)"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> Aft... [truncated message content] |
From: Web H. <web...@us...> - 2004-05-14 08:55:51
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8054/src/qat/parser/qaxmlparser Modified Files: QAXMLParser.java Added Files: BooleanExpression.java Log Message: Allow simple expressions in the onlyif attribute. Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QAXMLParser.java 13 May 2004 08:10:22 -0000 1.3 --- QAXMLParser.java 14 May 2004 08:55:41 -0000 1.4 *************** *** 1 **** ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int INCLUDE_NODE = 15; private static final int REPORT_NODE = 16; private static final int COMMENT_NODE = 17; private static final int TEXT_NODE = 18; private static final int IGNORE_NODE = 19; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int status = ProtocolConstants.PASSED; private LineNumberInputStream lineNumberInputStream; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(lineNumberInputStream=new LineNumberInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return status; } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> name="i"<br> start="0"<br> end="5"<br> inc="1"<br> echo message="The current value is ${i}"/><br> loop/><br> <br> Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processLoopNode(org.w3c.dom.Node loopNode) { try { org.w3c.dom.NamedNodeMap attributes = loopNode.getAttributes(); StringBuffer name = getAttribute(attributes,"name"); StringBuffer start = resolveVariable(getAttribute(attributes,"start", "0")); StringBuffer end = resolveVariable(getAttribute(attributes,"end")); StringBuffer inc = resolveVariable(getAttribute(attributes,"inc", "1")); printStream.println(loopNode.getNodeName()+" "+name+" from "+start+" by "+inc+" until "+end); int endint = Integer.parseInt(end.toString()); int incint = Integer.parseInt(inc.toString()); for (int loop_var = Integer.parseInt(start.toString()); loop_var <= endint; loop_var+=incint) { properties.put(name.toString(),Integer.toString(loop_var)); // now iterate through child elements of root org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { processNode(children.item(i)); } } // remove the variable declaration, since it should be // visible local to the loop block only properties.remove(name.toString()); // tag all the children so they don't get processed again org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { ignoreNodes.add(children.item(i)); } } catch (Exception e) { printError(LOOP_NODE,"invalid loop node ("+loopNode.toString()+")"); } } /** * This tag allows you to echo traces to the harness.<br> e.g. <echo message="A java property is ${java.home}"/> */ public void processEchoNode(org.w3c.dom.Node echoNode) { setStatusText(echoNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = echoNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer message = resolveVariable(getAttribute(attributes,"message")); printStream.println(HtmlPrintStream.GREEN,message.toString()); } } catch (Exception e) { printError(ECHO_NODE,"invalid echo node found ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <sendzip<br> onlyif="variable" (optional, execute only if variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processSendZipNode(org.w3c.dom.Node sendzipNode) { try { org.w3c.dom.NamedNodeMap attributes = sendzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(sendzipNode.getNodeName()+" "+agentid); printStream.println(sendzipNode.getNodeName()+" "+zipfile+" to agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); // send the zip file, and retrieve the associated zip ID try { properties.setProperty(agentid.toString()+zipfile.toString(), agentInstance.ZIPSEND(zipfile.toString(),agentid.toString()+zipfile.toString())); } catch (Exception ex) { printError(SENDZIP_NODE,"problem sending zip file to agent ("+ex.toString()+")"); } } else { printStream.println("sendzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <cleanzip<br> onlyif="variable" (optional, execute only of variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processCleanZipNode(org.w3c.dom.Node cleanzipNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(cleanzipNode.getNodeName()+" "+agentid); printStream.println(cleanzipNode.getNodeName()+" from agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); agentInstance.ZIPCLEAN(agentid.toString()+zipfile.toString()); properties.remove(agentid.toString()+zipfile.toString()); } else { printStream.println("cleanzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <start<br> processid="variable" (the id of the process for future reference)<br> agentid="agentid" (the id of the agent you want to start the process on)<br> command="command string" (the command you want to execute)<br> arguments="argument string" (the arguments to the command)<br> timeout="timeout" (the timeout for this command)<br> onlyif="variable"/> (optional - execute only if true)<br> */ public void processStartNode(org.w3c.dom.Node startNode) { try { org.w3c.dom.NamedNodeMap attributes = startNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processid = resolveVariable(getAttribute(attributes, "processid")); StringBuffer agentid = resolveVariable(getAttribute(attributes, "agentid")); StringBuffer command = resolveVariable(getAttribute(attributes, "command")); StringBuffer arguments = resolveVariable(getAttribute(attributes, "arguments","")); StringBuffer timeout = resolveVariable(getAttribute(attributes, "timeout","0")); setStatusText(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); printStream.println(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); // check that this process id is unused if (properties.getProperty(processid.toString())!=null) { throw new Exception("processid "+processid+" already exists"); } StringTokenizer tokens = new StringTokenizer(arguments.toString()," "); String[] cmdArray = new String[1+tokens.countTokens()]; cmdArray[0] = command.toString(); int i = 1; while(tokens.hasMoreTokens()) { cmdArray[i++] = tokens.nextToken(); } AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); properties.setProperty(processid.toString(), agentInstance.CMDSTART(cmdArray, timeout.toString())); } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(START_NODE,"invalid start node ("+e.toString()+")"); } } /** * This task will retrieve the status of an executed process.<br> e.g. <status<br> processid="variable" (the id of the process for future reference)<br> status="result" (the status of processid will be placed in this variable)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processStatusNode(org.w3c.dom.Node statusNode) { try { org.w3c.dom.NamedNodeMap attributes = statusNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); StringBuffer result = resolveVariable(getAttribute(attributes, "status")); setStatusText(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); printStream.println(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processidname); String statusCode = agentInstance.CMDSTATUS(processid.toString()); if (Integer.parseInt(statusCode)==0) properties.setProperty(result.toString(),"passed"); else properties.setProperty(result.toString(),"failed"); // now print out a message if the status was timed out int value = Integer.parseInt(statusCode); if (value == qat.agent.ExecProcess.TIMEDOUT_STATE) { printDebug("command "+processidname+" timed out!"); } else { if (value < 0) { printDebug("command "+processidname.toString()+" failed!"); } else { printDebug("command "+processidname.toString()+" exited normally"); } } } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(STATUS_NODE,"invalid status node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <trace<br> processid="variable" (the processid to retrieve the trace for)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processTraceNode(org.w3c.dom.Node traceNode) { try { org.w3c.dom.NamedNodeMap attributes = traceNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processid); agentInstance.CMDGETTRACE(processid.toString(), projectResultsDir+File.separator+ Common.getUniqueTestIdentifier(testPath)+"_"+processidname.toString()); addToPropertiesList(INTERNAL_TRACE_LIST,processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <clean<br> processid="variable" // the processid to retrieve the trace for<br> onlyif="result"/> // optional - execute only if true<br> */ public void processCleanNode(org.w3c.dom.Node cleanNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); setStatusText(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); printStream.println(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("Unknown processID :"+processid.toString()); agentInstance.CMDCLEAN(processid.toString()); properties.remove(processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <include<br> file="filename" // the file to include. May be either a QAXML file or a Java style properties file<br> onlyif="result"/> // optional - execute only if true<br> */ public void processIncludeNode(org.w3c.dom.Node includeNode) { try { org.w3c.dom.NamedNodeMap attributes = includeNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer fileName = resolveVariable(getAttribute(attributes,"filename")); // check if it exists File f = new File(fileName.toString()); if (!f.exists()) { throw new Exception("Include file not found :"+fileName); } // check if it's a .properties include or a .qinc/other type of file if (fileName.toString().toLowerCase().indexOf(Common.PROPERTIES_EXTENSION)>0) { printDebug("including properties file "+fileName.toString()); Properties newProperties = new Properties(); newProperties.load(new FileInputStream(fileName.toString())); properties = Utils.mergeProperties(properties,newProperties); propertiesIncludeList.add(fileName.toString()); } else { printDebug("including qaxml file "+fileName.toString()); QAXMLParser childParser = new QAXMLParser(); childParser.setStatusLabel(statusLabel); childParser.setProperties(properties); childParser.setTestPath(fileName.toString()); int includeStatus = childParser.parseFile(); Properties newProperties = childParser.getProperties(); properties = Utils.mergeProperties(properties,newProperties); if (includeStatus!=ProtocolConstants.PASSED) { if (status != ProtocolConstants.UNRESOLVED) { // unresolved always overrides any test result status = includeStatus; } } qaxmlIncludeList.add(fileName.toString()); } } else { printStream.println("ignoring include (onlyif "+onlyif+")"); } } catch (Exception e) { printError(INCLUDE_NODE,"problem with include file ("+e.toString()+") "); } } /** * This tag causes a global property to be set. <report status="passed, failed"/><br> Note, an unresolved result can not be over-ridden. */ public void processReportNode(org.w3c.dom.Node reportNode) { setStatusText(reportNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = reportNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer statusStr = resolveVariable(getAttribute(attributes,"status","failed")); setStatusText(reportNode.getNodeName()+" "+statusStr.toString()); printStream.println(reportNode.getNodeName()+" "+statusStr.toString()); // unresolved always overrides any test result if (status != ProtocolConstants.UNRESOLVED) { if (inEvaluationMode()) { status = ProtocolConstants.PASSED; } else { if (statusStr.toString().toLowerCase().equals("passed")) { status = ProtocolConstants.PASSED; } else { if (getTestBugInfo().equals("")) { status = ProtocolConstants.FAILED; } else { status = ProtocolConstants.PENDING; } } } } } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } private void addToPropertiesList(String key, String prop) { String list = properties.getProperty(key,""); prop = "\""+prop+"\""; if (list != null) { if (list.indexOf(prop)<0) properties.setProperty(key,list+" "+prop); } else { properties.setProperty(key,prop); } } /** * Looks through currently running agents for an identifier matching processID. * Returns the matching AgentInstance, or null if it wasn't found. */ private AgentInstance getAgentRunningProcess(StringBuffer processid) { try { AgentInstance agentInstance; for (Iterator e = agentMap.keySet().iterator() ; e.hasNext() ;) { agentInstance = (AgentInstance)agentMap.get(e.next()); if (agentInstance.isHandlingProcess(processid.toString())) { return agentInstance; } } } catch(Exception e) { printError(23,"no agent was running this process!"); } return null; } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName) { return getAttribute(attributes, attributeName, ""); } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName, String defaultValue) { org.w3c.dom.Node attribute = attributes.getNamedItem(attributeName); if (attribute !=null) return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); } private boolean isInterrupted() { return interrupted; } /** * This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files. */ public void interrupt() { interrupted = true; // now call kill for all active agents if (!inEvaluationMode()) { } } /** * This method retrieves the specified property from the results of parsing this file. */ public String getProperty(String key) { return "NOT YET IMPLEMENTED"; } /** * This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned. */ public String getProperty(String key, String defaultValue) { return "NOT YET IMPLEMENTED"; } /** * This method should return a test name which will be used to display the test in * the test tree. */ public String getTestName() { return name; } /** * This method should return a test Author which will be used to display the test in * the test tree. */ public String getTestAuthor() { return author; } /** * This method should return a test Description which will be used to display the test in * the test tree. */ public String getTestDescription() { return description; } /** * This method should return a test BugInfo which will be used for displaying the test in * the test tree. */ public String getTestBugInfo() { return buginfo; } /** * This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness. */ public String[] getKeyWords() { return new String[0]; } /** * This should return the list of files other than standard java.util.Properties files which were * included to parse this test file. */ public String[] getIncludeList() { String[] list = new String[qaxmlIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)qaxmlIncludeList.get(i); } return list; } /** * This should return the list of standard java.util.Properties files which were * included to parse this test file. */ public String[] getPropertiesIncludeList() { String[] list = new String[propertiesIncludeList.size()]; for (int i = 0; i < list.length; i++) { list[i] = (String)propertiesIncludeList.get(i); } return list; } /** * This method should list all available output files produced by this test when run on the agent, * but relative to the harness. */ public String[] getTraceList() { return Utils.toStringArray(properties.getProperty(INTERNAL_TRACE_LIST).toString()); } /** * This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness. */ public void prepare(String projectResultsDir) { this.projectResultsDir = projectResultsDir; } /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. */ public PrintStream openPrintStream(String fileName) throws java.io.FileNotFoundException { return new HtmlPrintStream(new PrintStream(new FileOutputStream(fileName),true),true); } /* * This method centralises all the traces printed by the parser. */ public void printDebug(String msg) { } /** * This method indicates we are finished with this parser, and disposes * any reserved resources. */ public void finish() { } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public void setStatusLabel(JLabel status) { statusLabel = status; } private void setStatusText(String s) { if (!inEvaluationMode()) statusLabel.setText(s); } private void printError(int code, String msg) { status = ProtocolConstants.FAILED; printStream.printBold("[ "); printStream.print(HtmlPrintStream.RED,"Error "); printStream.print("("); printStream.print(code); printStream.print(") :"); printStream.print(msg); printStream.print(" on line "+lineNumberInputStream.getLineNumber()); printStream.print(" in file "); printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Throwable t) { t.printStackTrace(); } } public StringBuffer resolveVariable(StringBuffer expression) throws Exception { return QAXMLExpression.resolveVariable(expression,properties); } public static final void main(String args[]) { try { System.getProperties().setProperty("qat.agent.count","1"); System.getProperties().setProperty("agent1.name","triolet"); System.getProperties().setProperty("agent1.port","9000"); QAXMLParser parser = new QAXMLParser(); parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); parser.setProperties(System.getProperties()); parser.setPrintStream(System.out, false); parser.setEvaluationMode(true); parser.setStatusLabel(new JLabel()); parser.parseFile(); } catch (Throwable t) { t.printStackTrace(); } } } \ No newline at end of file --- 1 ---- ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int INCLUDE_NODE = 15; private static final int REPORT_NODE = 16; private static final int COMMENT_NODE = 17; private static final int TEXT_NODE = 18; private static final int IGNORE_NODE = 19; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int statusCode = ProtocolConstants.PASSED; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); setStatus(ProtocolConstants.PASSED); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(new BufferedInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return getStatus(); } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); setStatus(ProtocolConstants.UNRESOLVED); printError(-1,"Unknown node type ("+nodeType+") "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = printEnvNode.getAttributes(); if (onlyIf(attributes)) { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } else { printStream.println("printenv ignored (onlyif false)"); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); if (onlyIf(attributes)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif false)"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } else { printStream.println("property "+getAttribute(attributes,"name")+" ignored (onlyif false)"); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); if (onlyIf(attributes)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif false)"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); if (onlyIf(attributes)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif false)"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (onlyIf(attributes)) { if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agent... [truncated message content] |
From: Web H. <web...@us...> - 2004-05-13 08:10:34
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5834/qat/parser/qaxmlparser Modified Files: QAXMLParser.java Log Message: Added include tag to include properties and qaxml files. Removed printed stack trace from JUnit test finder. Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QAXMLParser.java 4 May 2004 16:02:00 -0000 1.2 --- QAXMLParser.java 13 May 2004 08:10:22 -0000 1.3 *************** *** 1 **** ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int REPORT_NODE = 15; private static final int COMMENT_NODE = 16; private static final int TEXT_NODE = 17; private static final int IGNORE_NODE = 18; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int status = ProtocolConstants.PASSED; private LineNumberInputStream lineNumberInputStream; private String projectResultsDir; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(lineNumberInputStream=new LineNumberInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return status; } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> name="i"<br> start="0"<br> end="5"<br> inc="1"<br> echo message="The current value is ${i}"/><br> loop/><br> <br> Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processLoopNode(org.w3c.dom.Node loopNode) { try { org.w3c.dom.NamedNodeMap attributes = loopNode.getAttributes(); StringBuffer name = getAttribute(attributes,"name"); StringBuffer start = resolveVariable(getAttribute(attributes,"start", "0")); StringBuffer end = resolveVariable(getAttribute(attributes,"end")); StringBuffer inc = resolveVariable(getAttribute(attributes,"inc", "1")); printStream.println(loopNode.getNodeName()+" "+name+" from "+start+" by "+inc+" until "+end); int endint = Integer.parseInt(end.toString()); int incint = Integer.parseInt(inc.toString()); for (int loop_var = Integer.parseInt(start.toString()); loop_var <= endint; loop_var+=incint) { properties.put(name.toString(),Integer.toString(loop_var)); // now iterate through child elements of root org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { processNode(children.item(i)); } } // remove the variable declaration, since it should be // visible local to the loop block only properties.remove(name.toString()); // tag all the children so they don't get processed again org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { ignoreNodes.add(children.item(i)); } } catch (Exception e) { printError(LOOP_NODE,"invalid loop node ("+loopNode.toString()+")"); } } /** * This tag allows you to echo traces to the harness.<br> e.g. <echo message="A java property is ${java.home}"/> */ public void processEchoNode(org.w3c.dom.Node echoNode) { setStatusText(echoNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = echoNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer message = resolveVariable(getAttribute(attributes,"message")); printStream.println(HtmlPrintStream.GREEN,message.toString()); } } catch (Exception e) { printError(ECHO_NODE,"invalid echo node found ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <sendzip<br> onlyif="variable" (optional, execute only if variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processSendZipNode(org.w3c.dom.Node sendzipNode) { try { org.w3c.dom.NamedNodeMap attributes = sendzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(sendzipNode.getNodeName()+" "+agentid); printStream.println(sendzipNode.getNodeName()+" "+zipfile+" to agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); // send the zip file, and retrieve the associated zip ID try { properties.setProperty(agentid.toString()+zipfile.toString(), agentInstance.ZIPSEND(zipfile.toString(),agentid.toString()+zipfile.toString())); } catch (Exception ex) { printError(SENDZIP_NODE,"problem sending zip file to agent ("+ex.toString()+")"); } } else { printStream.println("sendzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <cleanzip<br> onlyif="variable" (optional, execute only of variable="true")<br> agentid="agentid" (the id of the agent you want to send the zip to)<br> zipfile="zipfile"/><br> */ public void processCleanZipNode(org.w3c.dom.Node cleanzipNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(cleanzipNode.getNodeName()+" "+agentid); printStream.println(cleanzipNode.getNodeName()+" from agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); agentInstance.ZIPCLEAN(agentid.toString()+zipfile.toString()); properties.remove(agentid.toString()+zipfile.toString()); } else { printStream.println("cleanzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <start<br> processid="variable" (the id of the process for future reference)<br> agentid="agentid" (the id of the agent you want to start the process on)<br> command="command string" (the command you want to execute)<br> arguments="argument string" (the arguments to the command)<br> timeout="timeout" (the timeout for this command)<br> onlyif="variable"/> (optional - execute only if true)<br> */ public void processStartNode(org.w3c.dom.Node startNode) { try { org.w3c.dom.NamedNodeMap attributes = startNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processid = resolveVariable(getAttribute(attributes, "processid")); StringBuffer agentid = resolveVariable(getAttribute(attributes, "agentid")); StringBuffer command = resolveVariable(getAttribute(attributes, "command")); StringBuffer arguments = resolveVariable(getAttribute(attributes, "arguments","")); StringBuffer timeout = resolveVariable(getAttribute(attributes, "timeout","0")); setStatusText(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); printStream.println(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); // check that this process id is unused if (properties.getProperty(processid.toString())!=null) { throw new Exception("processid "+processid+" already exists"); } StringTokenizer tokens = new StringTokenizer(arguments.toString()," "); String[] cmdArray = new String[1+tokens.countTokens()]; cmdArray[0] = command.toString(); int i = 1; while(tokens.hasMoreTokens()) { cmdArray[i++] = tokens.nextToken(); } AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); properties.setProperty(processid.toString(), agentInstance.CMDSTART(cmdArray, timeout.toString())); } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(START_NODE,"invalid start node ("+e.toString()+")"); } } /** * This task will retrieve the status of an executed process.<br> e.g. <status<br> processid="variable" (the id of the process for future reference)<br> status="result" (the status of processid will be placed in this variable)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processStatusNode(org.w3c.dom.Node statusNode) { try { org.w3c.dom.NamedNodeMap attributes = statusNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); StringBuffer result = resolveVariable(getAttribute(attributes, "status")); setStatusText(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); printStream.println(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processidname); String statusCode = agentInstance.CMDSTATUS(processid.toString()); if (Integer.parseInt(statusCode)==0) properties.setProperty(result.toString(),"passed"); else properties.setProperty(result.toString(),"failed"); // now print out a message if the status was timed out int value = Integer.parseInt(statusCode); if (value == qat.agent.ExecProcess.TIMEDOUT_STATE) { printDebug("command "+processidname+" timed out!"); } else { if (value < 0) { printDebug("command "+processidname.toString()+" failed!"); } else { printDebug("command "+processidname.toString()+" exited normally"); } } } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(STATUS_NODE,"invalid status node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <trace<br> processid="variable" (the processid to retrieve the trace for)<br> onlyif="result"/> (optional - execute only if true)<br> */ public void processTraceNode(org.w3c.dom.Node traceNode) { try { org.w3c.dom.NamedNodeMap attributes = traceNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processid); agentInstance.CMDGETTRACE(processid.toString(), projectResultsDir+File.separator+ Common.getUniqueTestIdentifier(testPath)+"_"+processidname.toString()); addToPropertiesList(INTERNAL_TRACE_LIST,processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> e.g. <clean<br> processid="variable" // the processid to retrieve the trace for<br> onlyif="result"/> // optional - execute only if true<br> */ public void processCleanNode(org.w3c.dom.Node cleanNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); setStatusText(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); printStream.println(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("Unknown processID :"+processid.toString()); agentInstance.CMDCLEAN(processid.toString()); properties.remove(processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This tag causes a global property to be set. <report status="passed, failed"/><br> Note, an unresolved result can not be over-ridden. */ public void processReportNode(org.w3c.dom.Node reportNode) { setStatusText(reportNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = reportNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer statusStr = resolveVariable(getAttribute(attributes,"status","failed")); setStatusText(reportNode.getNodeName()+" "+statusStr.toString()); printStream.println(reportNode.getNodeName()+" "+statusStr.toString()); // unresolved always overrides any test result if (status != ProtocolConstants.UNRESOLVED) { if (inEvaluationMode()) { status = ProtocolConstants.PASSED; } else { if (statusStr.toString().toLowerCase().equals("passed")) { status = ProtocolConstants.PASSED; } else { if (getTestBugInfo().equals("")) { status = ProtocolConstants.FAILED; } else { status = ProtocolConstants.PENDING; } } } } } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } private void addToPropertiesList(String key, String prop) { String list = properties.getProperty(key,""); prop = "\""+prop+"\""; if (list != null) { if (list.indexOf(prop)<0) properties.setProperty(key,list+" "+prop); } else { properties.setProperty(key,prop); } } /** * Looks through currently running agents for an identifier matching processID. * Returns the matching AgentInstance, or null if it wasn't found. */ private AgentInstance getAgentRunningProcess(StringBuffer processid) { try { AgentInstance agentInstance; for (Iterator e = agentMap.keySet().iterator() ; e.hasNext() ;) { agentInstance = (AgentInstance)agentMap.get(e.next()); if (agentInstance.isHandlingProcess(processid.toString())) { return agentInstance; } } } catch(Exception e) { printError(23,"no agent was running this process!"); } return null; } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName) { return getAttribute(attributes, attributeName, ""); } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName, String defaultValue) { org.w3c.dom.Node attribute = attributes.getNamedItem(attributeName); if (attribute !=null) return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); } private boolean isInterrupted() { return interrupted; } /** * This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files. */ public void interrupt() { interrupted = true; // now call kill for all active agents if (!inEvaluationMode()) { } } /** * This method retrieves the specified property from the results of parsing this file. */ public String getProperty(String key) { return "NOT YET IMPLEMENTED"; } /** * This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned. */ public String getProperty(String key, String defaultValue) { return "NOT YET IMPLEMENTED"; } /** * This method should return a test name which will be used to display the test in * the test tree. */ public String getTestName() { return name; } /** * This method should return a test Author which will be used to display the test in * the test tree. */ public String getTestAuthor() { return author; } /** * This method should return a test Description which will be used to display the test in * the test tree. */ public String getTestDescription() { return description; } /** * This method should return a test BugInfo which will be used for displaying the test in * the test tree. */ public String getTestBugInfo() { return buginfo; } /** * This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness. */ public String[] getKeyWords() { return new String[0]; } /** * This should return the list of files other than standard java.util.Properties files which were * included to parse this test file. */ public String[] getIncludeList() { return new String[0]; } /** * This should return the list of standard java.util.Properties files which were * included to parse this test file. */ public String[] getPropertiesIncludeList() { return new String[0]; } /** * This method should list all available output files produced by this test when run on the agent, * but relative to the harness. */ public String[] getTraceList() { return Utils.toStringArray(properties.getProperty(INTERNAL_TRACE_LIST).toString()); } /** * This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness. */ public void prepare(String projectResultsDir) { this.projectResultsDir = projectResultsDir; } /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. */ public PrintStream openPrintStream(String fileName) throws java.io.FileNotFoundException { return new HtmlPrintStream(new PrintStream(new FileOutputStream(fileName),true),true); } /* * This method centralises all the traces printed by the parser. */ public void printDebug(String msg) { } /** * This method indicates we are finished with this parser, and disposes * any reserved resources. */ public void finish() { } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public void setStatusLabel(JLabel status) { statusLabel = status; } private void setStatusText(String s) { if (!inEvaluationMode()) statusLabel.setText(s); } private void printError(int code, String msg) { status = ProtocolConstants.FAILED; printStream.printBold("[ "); printStream.print(HtmlPrintStream.RED,"Error "); printStream.print("("); printStream.print(code); printStream.print(") :"); printStream.print(msg); printStream.print(" on line "+lineNumberInputStream.getLineNumber()); printStream.print(" in file "); printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Throwable t) { t.printStackTrace(); } } public StringBuffer resolveVariable(StringBuffer expression) throws Exception { return QAXMLExpression.resolveVariable(expression,properties); } public static final void main(String args[]) { try { System.getProperties().setProperty("qat.agent.count","1"); System.getProperties().setProperty("agent1.name","triolet"); System.getProperties().setProperty("agent1.port","9000"); QAXMLParser parser = new QAXMLParser(); parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); parser.setProperties(System.getProperties()); parser.setPrintStream(System.out, false); parser.setEvaluationMode(true); parser.setStatusLabel(new JLabel()); parser.parseFile(); } catch (Throwable t) { t.printStackTrace(); } } } \ No newline at end of file --- 1 ---- ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int INCLUDE_NODE = 15; private static final int REPORT_NODE = 16; private static final int COMMENT_NODE = 17; private static final int TEXT_NODE = 18; private static final int IGNORE_NODE = 19; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "include", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int status = ProtocolConstants.PASSED; private LineNumberInputStream lineNumberInputStream; private String projectResultsDir; private List qaxmlIncludeList, propertiesIncludeList; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); qaxmlIncludeList = new java.util.ArrayList(); propertiesIncludeList = new java.util.ArrayList(); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(lineNumberInputStream=new LineNumberInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return status; } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case INCLUDE_NODE : processIncludeNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> ... [truncated message content] |
From: Web H. <web...@us...> - 2004-05-13 08:10:33
|
Update of /cvsroot/qat/QAT/src/qat/parser/junitparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5834/qat/parser/junitparser Modified Files: JUnitTestFinder.java Log Message: Added include tag to include properties and qaxml files. Removed printed stack trace from JUnit test finder. Index: JUnitTestFinder.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/junitparser/JUnitTestFinder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JUnitTestFinder.java 3 Jun 2003 14:41:11 -0000 1.1 --- JUnitTestFinder.java 13 May 2004 08:10:21 -0000 1.2 *************** *** 1 **** ! package qat.parser.junitparser; // JDK imports import java.io.File; import java.net.URL; import java.net.URLClassLoader; // qat imports import qat.parser.TestFinderInterface; import qat.parser.ParserInterface; public class JUnitTestFinder extends Object implements TestFinderInterface { /** * This is the file extension this TestFinder uses to determine whether a file will be * treated as a test or not. */ private static final String TEST_FILE_SUFFIX = ".class"; private String rootDirectory; private FileClassLoader classLoader; public JUnitTestFinder() { } public void setProjectRoot(String rootDirectory) { this.rootDirectory = rootDirectory; try { classLoader = new FileClassLoader(rootDirectory); } catch (Throwable t) { t.printStackTrace(); } } /** * Return true if this file is a JUnit file. */ public boolean isTestFile(File file) { if ((file.getName().toLowerCase().endsWith(TEST_FILE_SUFFIX))&& (!isExcludePath(file))) { try { String className = convertPathToClassName(file.getCanonicalPath(),rootDirectory); //System.out.println("Trying too load "+className+" from root "+rootDirectory); Class possibleTest = classLoader.loadClass(className); //System.out.println("possibleTest="+possibleTest); return (junit.framework.TestCase.class.isAssignableFrom(possibleTest)); } catch (Throwable t) { t.printStackTrace(); } } return false; } public static String convertPathToClassName(String pathToFile, String rootDirectory) { String className; // remove the suffix className = pathToFile.substring(0,pathToFile.lastIndexOf(TEST_FILE_SUFFIX)); // remove the root path info className = className.substring(className.indexOf(rootDirectory)+rootDirectory.length()+1, className.length()); // convert to package name className = className.replace('\\','.'); className = className.replace('/','.'); return className; } private boolean isExcludePath(File file) { String path = file.getPath(); return ((path.indexOf("SCCS")>=0)| (path.indexOf("deleted_files")>=0)); } /** * Return a parser for the specified file type, or null * if it's not one we recognise. */ public ParserInterface getParser(File file) { if (isTestFile(file)) { JUnitParser parser = new qat.parser.junitparser.JUnitParser(); parser.setProjectRoot(rootDirectory); return parser; } return null; } } \ No newline at end of file --- 1 ---- ! package qat.parser.junitparser; // JDK imports import java.io.File; import java.net.URL; import java.net.URLClassLoader; // qat imports import qat.parser.TestFinderInterface; import qat.parser.ParserInterface; public class JUnitTestFinder extends Object implements TestFinderInterface { /** * This is the file extension this TestFinder uses to determine whether a file will be * treated as a test or not. */ private static final String TEST_FILE_SUFFIX = ".class"; private String rootDirectory; private FileClassLoader classLoader; public JUnitTestFinder() { } public void setProjectRoot(String rootDirectory) { this.rootDirectory = rootDirectory; try { classLoader = new FileClassLoader(rootDirectory); } catch (Throwable t) { t.printStackTrace(); } } /** * Return true if this file is a JUnit file. */ public boolean isTestFile(File file) { if ((file.getName().toLowerCase().endsWith(TEST_FILE_SUFFIX))&& (!isExcludePath(file))) { try { String className = convertPathToClassName(file.getCanonicalPath(),rootDirectory); //System.out.println("Trying too load "+className+" from root "+rootDirectory); Class possibleTest = classLoader.loadClass(className); //System.out.println("possibleTest="+possibleTest); return (junit.framework.TestCase.class.isAssignableFrom(possibleTest)); } catch (Throwable t) { // not a test file - ignore it // t.printStackTrace(); } } return false; } public static String convertPathToClassName(String pathToFile, String rootDirectory) { String className; // remove the suffix className = pathToFile.substring(0,pathToFile.lastIndexOf(TEST_FILE_SUFFIX)); // remove the root path info className = className.substring(className.indexOf(rootDirectory)+rootDirectory.length()+1, className.length()); // convert to package name className = className.replace('\\','.'); className = className.replace('/','.'); return className; } private boolean isExcludePath(File file) { String path = file.getPath(); return ((path.indexOf("SCCS")>=0)| (path.indexOf("deleted_files")>=0)); } /** * Return a parser for the specified file type, or null * if it's not one we recognise. */ public ParserInterface getParser(File file) { if (isTestFile(file)) { JUnitParser parser = new qat.parser.junitparser.JUnitParser(); parser.setProjectRoot(rootDirectory); return parser; } return null; } } \ No newline at end of file |
From: Web H. <web...@us...> - 2004-05-13 08:09:07
|
Update of /cvsroot/qat/QAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5630 Modified Files: build.xml Log Message: No longer update the jar file, build it direct. Index: build.xml =================================================================== RCS file: /cvsroot/qat/QAT/build.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** build.xml 4 May 2004 16:30:23 -0000 1.19 --- build.xml 13 May 2004 08:08:56 -0000 1.20 *************** *** 101,105 **** depends="compile" description="create the QAT jar file."> ! <jar jarfile="${build.jar.dir}/${qat.jar.name}" update="yes"> <fileset dir="${build.class.dir}" /> <fileset dir="${source.dir}" casesensitive="yes" > --- 101,105 ---- depends="compile" description="create the QAT jar file."> ! <jar jarfile="${build.jar.dir}/${qat.jar.name}" update="no"> <fileset dir="${build.class.dir}" /> <fileset dir="${source.dir}" casesensitive="yes" > |
From: Web H. <web...@us...> - 2004-05-04 16:30:38
|
Update of /cvsroot/qat/QAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27728 Modified Files: build.xml Log Message: Fixed bad link to API docs Index: build.xml =================================================================== RCS file: /cvsroot/qat/QAT/build.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** build.xml 4 May 2004 16:01:59 -0000 1.18 --- build.xml 4 May 2004 16:30:23 -0000 1.19 *************** *** 129,133 **** <target name="distrib" ! depends="jar" description="generate QAT binary distribution."> <!-- compile and build the examples zip/classes --> --- 129,133 ---- <target name="distrib" ! depends="jar, javadoc" description="generate QAT binary distribution."> <!-- compile and build the examples zip/classes --> *************** *** 140,144 **** <zipfileset dir="${examples.dir}" prefix="${distrib.prefix}/examples" /> <zipfileset dir="${specification.dir}" prefix="${distrib.prefix}/specification" /> ! <zipfileset dir="${build.javadoc.dir}" prefix="${distrib.prefix}/doc/api" /> </zip> </target> --- 140,144 ---- <zipfileset dir="${examples.dir}" prefix="${distrib.prefix}/examples" /> <zipfileset dir="${specification.dir}" prefix="${distrib.prefix}/specification" /> ! <zipfileset dir="${build.javadoc.dir}" prefix="${distrib.prefix}/doc/documentation/api" /> </zip> </target> |
From: Web H. <web...@us...> - 2004-05-04 16:02:38
|
Update of /cvsroot/qat/QAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22541 Modified Files: build.xml Log Message: updated javadocs Index: build.xml =================================================================== RCS file: /cvsroot/qat/QAT/build.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** build.xml 21 Oct 2003 17:07:19 -0000 1.17 --- build.xml 4 May 2004 16:01:59 -0000 1.18 *************** *** 156,161 **** depends="init" description="generate QAT javadoc."> ! <setproxy proxyhost="cornillon" proxyport="8000"/> ! <javadoc packagenames="* ,qat.gui.* ,qat.common.* ,qat.parser.* ,qat.qashparser.* ,qat.agent.* ,qat.components.* ,qat.plugins.*" sourcepath="${source.dir}" defaultexcludes="yes" --- 156,160 ---- depends="init" description="generate QAT javadoc."> ! <javadoc packagenames="qat.gui.* ,qat.common.* ,qat.parser.* ,qat.agent.* ,qat.components.* ,qat.plugins.*" sourcepath="${source.dir}" defaultexcludes="yes" *************** *** 164,173 **** version="true" use="true" windowtitle="QAT"> <classpath refid="QAT.compile.classpath"/> <doctitle><![CDATA[<h1>QAT</h1>]]></doctitle> ! <bottom><![CDATA[<i>See sourceforge for licensing details</i>]]></bottom> ! <tag name="todo" scope="all" description="To do:" /> ! <link href="${java.api.href}"/> </javadoc> </target> --- 163,171 ---- version="true" use="true" + breakiterator="yes" windowtitle="QAT"> <classpath refid="QAT.compile.classpath"/> <doctitle><![CDATA[<h1>QAT</h1>]]></doctitle> ! <bottom><![CDATA[<i>See <a href="http://sourceforge.net/projects/qat/">QAT</a> project for licensing details</i>]]></bottom> </javadoc> </target> |
From: Web H. <web...@us...> - 2004-05-04 16:02:08
|
Update of /cvsroot/qat/QAT/src/qat/parser/qaxmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22541/src/qat/parser/qaxmlparser Modified Files: QAXMLParser.java Log Message: updated javadocs Index: QAXMLParser.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/parser/qaxmlparser/QAXMLParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QAXMLParser.java 3 Jun 2003 14:41:11 -0000 1.1 --- QAXMLParser.java 4 May 2004 16:02:00 -0000 1.2 *************** *** 1 **** ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int REPORT_NODE = 15; private static final int COMMENT_NODE = 16; private static final int TEXT_NODE = 17; private static final int IGNORE_NODE = 18; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int status = ProtocolConstants.PASSED; private LineNumberInputStream lineNumberInputStream; private String projectResultsDir; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(lineNumberInputStream=new LineNumberInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return status; } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This tag is the start point for a single unit test.<br> * e.g. <sleep<br> * name="test name"<br> * author="test author"<br> * description="this is a description of the test"<br> * buginfo="any important bug information associated with this test" /><br> */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> * e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified * period of time.<br> * e.g. <sleep<br> * onlyif="variable"<br> * seconds="10"<br> * minutes="0"<br> * hours="0" /><br> * At least one of the attributes must be specified, any which are missing are * assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set. * Two forms may be used :<br> * e.g. 1) <property name="mypropertyname" value="mypropertyvalue" /><br> * e.g. 2) <property name="mypropertyname" refid="${someotherproperty}" /> <br> * which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> * e.g. <requestagent<br> * onlyif="variable"<br> // optional * agentid="agentid"<br> // the id of the agent you want to use * agentworkdir="workdir" /> // optional <br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> * e.g. <releaseagent<br> * onlyif="variable"<br> * agentid="agentid" /><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> * e.g. <checkagent<br> * result="result"<br> * agentid="1" /><br> * If the agent is found to be running, result will be set to "true", and all the agent properties * will be then be available in the QAXML script. If there was a problem contacting the * agent, result will be set to "false". * When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, * so the method will always return true. The environment properties of the script will be used * to re-create a set of properties as would be returned by the agent.<br> * After a succesfull call to this method, all java properties of the agent will be set locally, * with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates * to true.<br> * e.g. <loop<br> * name="i"<br> * start="0"<br> * end="5"<br> * inc="1" /><br> * <echo message="The current value is ${i}"/><br> * <loop/><br> * <br> * Which is equivalent to "for (int i = 0; i <= 5; i+=1) ...." * At least one of the attributes must be specified, any which are missing are * assumed to be zero. */ public void processLoopNode(org.w3c.dom.Node loopNode) { try { org.w3c.dom.NamedNodeMap attributes = loopNode.getAttributes(); StringBuffer name = getAttribute(attributes,"name"); StringBuffer start = resolveVariable(getAttribute(attributes,"start", "0")); StringBuffer end = resolveVariable(getAttribute(attributes,"end")); StringBuffer inc = resolveVariable(getAttribute(attributes,"inc", "1")); printStream.println(loopNode.getNodeName()+" "+name+" from "+start+" by "+inc+" until "+end); int endint = Integer.parseInt(end.toString()); int incint = Integer.parseInt(inc.toString()); for (int loop_var = Integer.parseInt(start.toString()); loop_var <= endint; loop_var+=incint) { properties.put(name.toString(),Integer.toString(loop_var)); // now iterate through child elements of root org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { processNode(children.item(i)); } } // remove the variable declaration, since it should be // visible local to the loop block only properties.remove(name.toString()); // tag all the children so they don't get processed again org.w3c.dom.NodeList children = loopNode.getChildNodes(); for ( int i = 0; i < children.getLength(); i++) { ignoreNodes.add(children.item(i)); } } catch (Exception e) { printError(LOOP_NODE,"invalid loop node ("+loopNode.toString()+")"); } } /** * This tag allows you to echo traces to the harness.<br> * e.g. <echo message="A java property is ${java.home}"/> */ public void processEchoNode(org.w3c.dom.Node echoNode) { setStatusText(echoNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = echoNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer message = resolveVariable(getAttribute(attributes,"message")); printStream.println(HtmlPrintStream.GREEN,message.toString()); } } catch (Exception e) { printError(ECHO_NODE,"invalid echo node found ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> * e.g. <sendzip<br> * onlyif="variable"<br> // optional, execute only of variable="true" * agentid="agentid"<br> // the id of the agent you want to send the zip to * zipfile="zipfile" /><br> */ public void processSendZipNode(org.w3c.dom.Node sendzipNode) { try { org.w3c.dom.NamedNodeMap attributes = sendzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(sendzipNode.getNodeName()+" "+agentid); printStream.println(sendzipNode.getNodeName()+" "+zipfile+" to agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); // send the zip file, and retrieve the associated zip ID try { properties.setProperty(agentid.toString()+zipfile.toString(), agentInstance.ZIPSEND(zipfile.toString(),agentid.toString()+zipfile.toString())); } catch (Exception ex) { printError(SENDZIP_NODE,"problem sending zip file to agent ("+ex.toString()+")"); } } else { printStream.println("sendzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> * e.g. <cleanzip<br> * onlyif="variable"<br> // optional, execute only of variable="true" * agentid="agentid"<br> // the id of the agent you want to send the zip to * zipfile="zipfile" /><br> */ public void processCleanZipNode(org.w3c.dom.Node cleanzipNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanzipNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer zipfile = resolveVariable(getAttribute(attributes,"zipfile")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { setStatusText(cleanzipNode.getNodeName()+" "+agentid); printStream.println(cleanzipNode.getNodeName()+" from agent "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); agentInstance.ZIPCLEAN(agentid.toString()+zipfile.toString()); properties.remove(agentid.toString()+zipfile.toString()); } else { printStream.println("cleanzip cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SENDZIP_NODE,"invalid sendzip node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> * e.g. <start<br> * processid="variable" // the id of the process for future reference<br> * agentid="agentid" // the id of the agent you want to start the process on<br> * command="command string" // the command you want to execute<br> * arguments="argument string" // the arguments to the command<br> * timeout="timeout" // the timeout for this command<br> * onlyif="variable" /> // optional - execute only if true<br> */ public void processStartNode(org.w3c.dom.Node startNode) { try { org.w3c.dom.NamedNodeMap attributes = startNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processid = resolveVariable(getAttribute(attributes, "processid")); StringBuffer agentid = resolveVariable(getAttribute(attributes, "agentid")); StringBuffer command = resolveVariable(getAttribute(attributes, "command")); StringBuffer arguments = resolveVariable(getAttribute(attributes, "arguments","")); StringBuffer timeout = resolveVariable(getAttribute(attributes, "timeout","0")); setStatusText(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); printStream.println(startNode.getNodeName()+" "+command.toString()+" "+arguments.toString()+" on agent "+agentid.toString()); // check that this process id is unused if (properties.getProperty(processid.toString())!=null) { throw new Exception("processid "+processid+" already exists"); } StringTokenizer tokens = new StringTokenizer(arguments.toString()," "); String[] cmdArray = new String[1+tokens.countTokens()]; cmdArray[0] = command.toString(); int i = 1; while(tokens.hasMoreTokens()) { cmdArray[i++] = tokens.nextToken(); } AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); if (agentInstance==null) throw new Exception("unknown agentid "+agentid); properties.setProperty(processid.toString(), agentInstance.CMDSTART(cmdArray, timeout.toString())); } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(START_NODE,"invalid start node ("+e.toString()+")"); } } /** * This task will retrieve the status of an executed process.<br> * e.g. <status<br> * processid="variable" // the id of the process for future reference<br> * status="result" // the status of processid will be placed in this variable<br> * onlyif="result"/> // optional - execute only if true<br> */ public void processStatusNode(org.w3c.dom.Node statusNode) { try { org.w3c.dom.NamedNodeMap attributes = statusNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); StringBuffer result = resolveVariable(getAttribute(attributes, "status")); setStatusText(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); printStream.println(statusNode.getNodeName()+" "+processidname.toString()+" "+result.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processidname); String statusCode = agentInstance.CMDSTATUS(processid.toString()); if (Integer.parseInt(statusCode)==0) properties.setProperty(result.toString(),"passed"); else properties.setProperty(result.toString(),"failed"); // now print out a message if the status was timed out int value = Integer.parseInt(statusCode); if (value == qat.agent.ExecProcess.TIMEDOUT_STATE) { printDebug("command "+processidname+" timed out!"); } else { if (value < 0) { printDebug("command "+processidname.toString()+" failed!"); } else { printDebug("command "+processidname.toString()+" exited normally"); } } } else { printStream.println("start cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(STATUS_NODE,"invalid status node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> * e.g. <trace<br> * processid="variable" // the processid to retrieve the trace for<br> * onlyif="result"/> // optional - execute only if true<br> */ public void processTraceNode(org.w3c.dom.Node traceNode) { try { org.w3c.dom.NamedNodeMap attributes = traceNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); processidname = resolveVariable(processidname); setStatusText(traceNode.getNodeName()+" "+processidname.toString()); printStream.println(traceNode.getNodeName()+" "+processidname.toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("unknown processid "+processid); agentInstance.CMDGETTRACE(processid.toString(), projectResultsDir+File.separator+ Common.getUniqueTestIdentifier(testPath)+"_"+processidname.toString()); addToPropertiesList(INTERNAL_TRACE_LIST,processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This task will retrieve the traces of an executed process.<br> * e.g. <clean<br> * processid="variable" // the processid to retrieve the trace for<br> * onlyif="result"/> // optional - execute only if true<br> */ public void processCleanNode(org.w3c.dom.Node cleanNode) { try { org.w3c.dom.NamedNodeMap attributes = cleanNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes, "onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer processidname = getAttribute(attributes, "processid"); StringBuffer processid = resolveVariable(processidname); processidname = QAXMLExpression.removeVariableBraces(processidname); setStatusText(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); printStream.println(cleanNode.getNodeName()+" "+resolveVariable(processidname).toString()); AgentInstance agentInstance = getAgentRunningProcess(processid); if (agentInstance==null) throw new Exception("Unknown processID :"+processid.toString()); agentInstance.CMDCLEAN(processid.toString()); properties.remove(processidname.toString()); } else { printStream.println("trace cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(TRACE_NODE,"invalid trace node ("+e.toString()+")"); } } /** * This tag causes a propery to be set. * Two forms may be used :<br> * <report status="passed, failed" /><br> * Note, an unresolved result can not be over-ridden. */ public void processReportNode(org.w3c.dom.Node reportNode) { setStatusText(reportNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = reportNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer statusStr = resolveVariable(getAttribute(attributes,"status","failed")); setStatusText(reportNode.getNodeName()+" "+statusStr.toString()); printStream.println(reportNode.getNodeName()+" "+statusStr.toString()); // unresolved always overrides any test result if (status != ProtocolConstants.UNRESOLVED) { if (inEvaluationMode()) { status = ProtocolConstants.PASSED; } else { if (statusStr.toString().toLowerCase().equals("passed")) { status = ProtocolConstants.PASSED; } else { if (getTestBugInfo().equals("")) { status = ProtocolConstants.FAILED; } else { status = ProtocolConstants.PENDING; } } } } } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } private void addToPropertiesList(String key, String prop) { String list = properties.getProperty(key,""); prop = "\""+prop+"\""; if (list != null) { if (list.indexOf(prop)<0) properties.setProperty(key,list+" "+prop); } else { properties.setProperty(key,prop); } } /** * Looks through currently running agents for an identifier matching processID. * Returns the matching AgentInstance, or null if it wasn't found. */ private AgentInstance getAgentRunningProcess(StringBuffer processid) { try { AgentInstance agentInstance; for (Iterator e = agentMap.keySet().iterator() ; e.hasNext() ;) { agentInstance = (AgentInstance)agentMap.get(e.next()); if (agentInstance.isHandlingProcess(processid.toString())) { return agentInstance; } } } catch(Exception e) { printError(23,"no agent was running this process!"); } return null; } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName) { return getAttribute(attributes, attributeName, ""); } /** * Simple wrapper function to handle exceptions when attributes are not set. */ private StringBuffer getAttribute(org.w3c.dom.NamedNodeMap attributes, String attributeName, String defaultValue) { org.w3c.dom.Node attribute = attributes.getNamedItem(attributeName); if (attribute !=null) return new StringBuffer(attribute.getNodeValue()); return new StringBuffer(defaultValue); } private boolean isInterrupted() { return interrupted; } /** * This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files. */ public void interrupt() { interrupted = true; // now call kill for all active agents if (!inEvaluationMode()) { } } /** * This method retrieves the specified property from the results of parsing this file. */ public String getProperty(String key) { return "NOT YET IMPLEMENTED"; } /** * This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned. */ public String getProperty(String key, String defaultValue) { return "NOT YET IMPLEMENTED"; } /** * This method should return a test name which will be used to display the test in * the test tree. */ public String getTestName() { return name; } /** * This method should return a test Author which will be used to display the test in * the test tree. */ public String getTestAuthor() { return author; } /** * This method should return a test Description which will be used to display the test in * the test tree. */ public String getTestDescription() { return description; } /** * This method should return a test BugInfo which will be used for displaying the test in * the test tree. */ public String getTestBugInfo() { return buginfo; } /** * This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness. */ public String[] getKeyWords() { return new String[0]; } /** * This should return the list of files other than standard java.util.Properties files which were * included to parse this test file. */ public String[] getIncludeList() { return new String[0]; } /** * This should return the list of standard java.util.Properties files which were * included to parse this test file. */ public String[] getPropertiesIncludeList() { return new String[0]; } /** * This method should list all available output files produced by this test when run on the agent, * but relative to the harness. */ public String[] getTraceList() { return Utils.toStringArray(properties.getProperty(INTERNAL_TRACE_LIST).toString()); } /** * This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness. */ public void prepare(String projectResultsDir) { this.projectResultsDir = projectResultsDir; } /** * Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test. */ public PrintStream openPrintStream(String fileName) throws java.io.FileNotFoundException { return new HtmlPrintStream(new PrintStream(new FileOutputStream(fileName),true),true); } /* * This method centralises all the traces printed by the parser. */ public void printDebug(String msg) { } /** * This method indicates we are finished with this parser, and disposes * any reserved resources. */ public void finish() { } /** * This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time. */ public void setStatusLabel(JLabel status) { statusLabel = status; } private void setStatusText(String s) { if (!inEvaluationMode()) statusLabel.setText(s); } private void printError(int code, String msg) { status = ProtocolConstants.FAILED; printStream.printBold("[ "); printStream.print(HtmlPrintStream.RED,"Error "); printStream.print("("); printStream.print(code); printStream.print(") :"); printStream.print(msg); printStream.print(" on line "+lineNumberInputStream.getLineNumber()); printStream.print(" in file "); printStream.print(HtmlPrintStream.RED,testPath); printStream.printBoldln(" ]"); } static { try { documentBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Throwable t) { t.printStackTrace(); } } public StringBuffer resolveVariable(StringBuffer expression) throws Exception { return QAXMLExpression.resolveVariable(expression,properties); } public static final void main(String args[]) { try { System.getProperties().setProperty("qat.agent.count","1"); System.getProperties().setProperty("agent1.name","triolet"); System.getProperties().setProperty("agent1.port","9000"); QAXMLParser parser = new QAXMLParser(); parser.setTestPath("examples"+File.separator+"qaxml_examples"+File.separator+"positive_tests"+File.separator+"pass_test_all_agents.qaxml"); parser.setProperties(System.getProperties()); parser.setPrintStream(System.out, false); parser.setEvaluationMode(true); parser.setStatusLabel(new JLabel()); parser.parseFile(); } catch (Throwable t) { t.printStackTrace(); } } } \ No newline at end of file --- 1 ---- ! package qat.parser.qaxmlparser; // JDK imports import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import javax.swing.*; // qat imports import qat.parser.ParserInterface; import qat.parser.AgentInstance; import qat.parser.HtmlPrintStream; import qat.common.Common; import qat.common.ProtocolConstants; import qat.common.Utils; import qat.agent.ExecProcess; /** * This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 * */ public class QAXMLParser extends Object implements ParserInterface { private static final String TRUE = "true"; private static final String FALSE = "false"; private static final String INTERNAL_TRACE_LIST = "qaxml.internal.traces"; private static javax.xml.parsers.DocumentBuilder documentBuilder; private static final int TEST_NODE = 0; private static final int PRINTENV_NODE = 1; private static final int SLEEP_NODE = 2; private static final int PROPERTY_NODE = 3; private static final int REQUESTAGENT_NODE = 4; private static final int RELEASEAGENT_NODE = 5; private static final int CHECKAGENT_NODE = 6; private static final int LOOP_NODE = 7; private static final int ECHO_NODE = 8; private static final int SENDZIP_NODE = 9; private static final int CLEANZIP_NODE = 10; private static final int START_NODE = 11; private static final int STATUS_NODE = 12; private static final int TRACE_NODE = 13; private static final int CLEAN_NODE = 14; private static final int REPORT_NODE = 15; private static final int COMMENT_NODE = 16; private static final int TEXT_NODE = 17; private static final int IGNORE_NODE = 18; private static final String keywords[] = {"test","printenv","sleep","property","requestagent","releaseagent", "checkagent","loop","echo","sendzip","cleanzip", "start","status","trace", "clean", "report", "#comment", "#text", "#ignore"}; private JLabel statusLabel; private boolean evaluating; private HtmlPrintStream printStream; private Properties properties; private String name, author, description, buginfo; private boolean interrupted = false; private String testPath; private java.util.HashMap agentMap; private int status = ProtocolConstants.PASSED; private LineNumberInputStream lineNumberInputStream; private String projectResultsDir; private java.util.ArrayList ignoreNodes; // nodes inside loops need only be processed once public QAXMLParser() { agentMap = new java.util.HashMap(); ignoreNodes = new java.util.ArrayList(); } /** * This method sets the path to root of the current project. */ public void setProjectRoot(String projectRoot) { // we don't need this method } /** * This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static. */ public String[] getSyntaxKeyWords() { return keywords; } /** * This method sets the path to file file containing the syntax * which will be parsed. */ public void setTestPath(String testPath) { this.testPath = testPath; } /** * This method sets the PrintStream to use for reporting errors * and other types of output from the script. */ public void setPrintStream(PrintStream printStream, boolean useHtml) { if (printStream instanceof HtmlPrintStream) { this.printStream = (HtmlPrintStream)printStream; } else { this.printStream = new HtmlPrintStream(printStream,useHtml); } } /** * This method sets any default properties which will be required * for parsing this file. */ public void setProperties(java.util.Properties p) { this.properties = p; properties.setProperty(INTERNAL_TRACE_LIST,properties.getProperty(INTERNAL_TRACE_LIST,"")); } /** * This method returns all the properties obtained by parsing this test file. */ public java.util.Properties getProperties() { return properties; } /** * If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing. */ public final void setEvaluationMode(boolean mode) { evaluating = mode; } public final boolean inEvaluationMode() { return evaluating; } /** * This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED */ public int parseFile() throws Exception { org.w3c.dom.Document document = documentBuilder.parse(lineNumberInputStream=new LineNumberInputStream(new FileInputStream(testPath))); org.w3c.dom.Element root = document.getDocumentElement(); org.w3c.dom.Node node; properties.setProperty("qaxml.basedir",new File(testPath).getParentFile().getCanonicalPath()); processNode(root); // check if all agents were cleaned up if (agentMap.size() > 0) { printError(REQUESTAGENT_NODE,"one or more agents not properly cleaned"); } return status; } private void processNode(org.w3c.dom.Node node) { int nodeType = getNodeType(node); switch (nodeType) { case IGNORE_NODE : // ignore already processed loop statements break; case COMMENT_NODE : // ignore comments break; case TEXT_NODE : // ignore text nodes break; case TEST_NODE : processTestNode(node); break; case PROPERTY_NODE : processPropertyNode(node); break; case PRINTENV_NODE : processPrintEnvNode(node); break; case SLEEP_NODE : processSleepNode(node); break; case REQUESTAGENT_NODE : processRequestAgentNode(node); break; case RELEASEAGENT_NODE : processReleaseAgentNode(node); break; case CHECKAGENT_NODE : processCheckAgentNode(node); break; case LOOP_NODE : processLoopNode(node); break; case ECHO_NODE : processEchoNode(node); break; case SENDZIP_NODE : processSendZipNode(node); break; case CLEANZIP_NODE : processCleanZipNode(node); break; case START_NODE : processStartNode(node); break; case STATUS_NODE : processStatusNode(node); break; case TRACE_NODE : processTraceNode(node); break; case CLEAN_NODE : processCleanNode(node); break; case REPORT_NODE : processReportNode(node); break; default : System.out.println("Unknown node type "+nodeType+" for node "+node.getNodeName()); } // now iterate through child elements org.w3c.dom.Node child = node.getFirstChild(); while(child != null) { processNode(child); child = child.getNextSibling(); } } private int getNodeType(org.w3c.dom.Node node) { if (ignoreNodes.remove(node)) return IGNORE_NODE; for (int i = 0; i < keywords.length; i++) if (keywords[i].equals(node.getNodeName())) return i; return -1; } /** * This <code>processTestNode</code> is the start point for a single unit test.<br> e.g. <test<br> name="test name"<br> author="test author"<br> description="this is a description of the test"<br> buginfo="any important bug information associated with this test"/><br> @param testNode an <code>org.w3c.dom.Node</code> value */ public void processTestNode(org.w3c.dom.Node testNode) { setStatusText(testNode.getNodeName()); try { if (testNode.hasAttributes()) { org.w3c.dom.NamedNodeMap attributes = testNode.getAttributes(); name = resolveVariable(getAttribute(attributes,"name")).toString(); author = resolveVariable(getAttribute(attributes,"author")).toString(); description = resolveVariable(getAttribute(attributes,"description")).toString(); buginfo = resolveVariable(getAttribute(attributes,"buginfo")).toString(); } } catch (Exception e) { printError(TEST_NODE,"invalid testnode found ("+testNode.toString()+")"); } } /** * This tag will print out the current environment settings.<br> e.g. <printenv/><br> */ public void processPrintEnvNode(org.w3c.dom.Node printEnvNode) { setStatusText(printEnvNode.getNodeName()); try { printStream.println("Defined variables:"); String key; for (java.util.Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); printStream.println(key+"="+properties.getProperty(key)); } } catch (Exception e) { printError(PRINTENV_NODE,"invalid printenv reported ("+printEnvNode.toString()+")"); } } /** * This tag will cause execution to sleep for the specified period of time.<br> e.g. <sleep<br> onlyif="variable"<br> seconds="10"<br> minutes="0"<br> hours="0"/><br> At least one of the attributes must be specified, any which are missing are assumed to be zero. */ public void processSleepNode(org.w3c.dom.Node sleepNode) { try { org.w3c.dom.NamedNodeMap attributes = sleepNode.getAttributes(); String timeS = resolveVariable(getAttribute(attributes,"seconds", "0")).toString(); String timeM = resolveVariable(getAttribute(attributes,"minutes", "0")).toString(); String timeH = resolveVariable(getAttribute(attributes,"hours", "0")).toString(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { int seconds = Integer.parseInt(timeS); seconds += 60*Integer.parseInt(timeM); seconds += 3600*Integer.parseInt(timeH); setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); if (!inEvaluationMode()) { printStream.println("sleeping for "+seconds+" seconds"); while((seconds>0)&&(!isInterrupted())) { Utils.safeSleep(1); seconds--; setStatusText(sleepNode.getNodeName()+" "+Integer.toString(seconds)); } } } else { printStream.println("sleep cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(SLEEP_NODE,"Invalid sleep node ("+sleepNode.toString()+")"); } } /** * This tag causes a propery to be set.<br> Two forms may be used :<br> e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/><br> e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/><br> which will first resolve the variable references, and then set the property. */ public void processPropertyNode(org.w3c.dom.Node propertyNode) { setStatusText(propertyNode.getNodeName()); try { org.w3c.dom.NamedNodeMap attributes = propertyNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer value = getAttribute(attributes,"value", ""); if (value.length()==0) value = resolveVariable(getAttribute(attributes,"refid", "")); properties.setProperty(getAttribute(attributes,"name").toString(),value.toString()); } } catch (Exception e) { printError(PROPERTY_NODE,"invalid property node ("+e.getMessage()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <requestagent<br> onlyif="variable" (optional) <br> agentid="agentid" (the id of the agent you want to use)<br> agentworkdir="workdir"/> (optional)<br> */ public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = requestAgentNode.getAttributes(); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); StringBuffer agentworkdir = resolveVariable(getAttribute(attributes,"agentworkdir","${"+agentid.toString()+".java.io.tmpdir}${"+agentid.toString()+".file.separator}agent"+agentid.toString())); printStream.println("requesting agent "+agentid+" at "+agenthost+":"+agentport+" with workdir "+agentworkdir); setStatusText(requestAgentNode.getNodeName()+" "+agentid); // check that this agentID is unused if (agentMap.get(agentid)!=null) { throw new Exception("agent identifier already exists :"+agentid.toString()); } AgentInstance agentInstance = new AgentInstance(agenthost.toString(), new Integer(agentport.toString()).intValue(), agentworkdir.toString(), inEvaluationMode()); agentMap.put(agentid.toString(),agentInstance); } else { printStream.println("request agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(REQUESTAGENT_NODE,"invalid requestagent node ("+e.toString()+")"); } } /** * This tag is the start point for a single unit test.<br> e.g. <releaseagent<br> onlyif="variable"<br> agentid="agentid"/><br> */ public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = releaseAgentNode.getAttributes(); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); StringBuffer onlyif = resolveVariable(getAttribute(attributes,"onlyif",TRUE)); if (onlyif.toString().equals(TRUE)) { printStream.println("releasing agent "+agentid); setStatusText(releaseAgentNode.getNodeName()+" "+agentid); AgentInstance agentInstance = (AgentInstance)agentMap.get(agentid.toString()); // remove also returns the object it deleted if (agentInstance==null) throw new Exception("unknown agentid "+agentid); try { agentInstance.DELAGENT(); } catch (Exception ex) { printError(RELEASEAGENT_NODE,"error cleaning up agent "+agentid+"("+ex.toString()+") :"); } finally { // unset this agentID property agentMap.remove(agentid.toString()); } } else { printStream.println("release agent cancelled (onlyif "+onlyif+")"); } } catch (Exception e) { printError(RELEASEAGENT_NODE,"invalid releaseagent node ("+e.getMessage()+")"); } } /** * This tag checks if an agent is running.<br> e.g. <checkagent<br> result="result"<br> agentid="1"/><br> If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.<br> After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home" */ public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode) { try { org.w3c.dom.NamedNodeMap attributes = checkAgentNode.getAttributes(); StringBuffer result = resolveVariable(getAttribute(attributes,"result")); StringBuffer agentid = resolveVariable(getAttribute(attributes,"agentid")); java.net.Socket socket = null; java.io.DataInputStream inStream = null; java.io.DataOutputStream outStream = null; String resultCode =FALSE; if (!inEvaluationMode()) { try { StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); printStream.println("checking agent at "+agenthost+":"+agentport); setStatusText(checkAgentNode.getNodeName()); setStatusText(checkAgentNode.getNodeName()+" "+agentid); socket = new java.net.Socket(agenthost.toString(),(new Integer(agentport.toString())).intValue()); socket.setSoTimeout(3000); inStream = new DataInputStream(socket.getInputStream()); outStream = new DataOutputStream(socket.getOutputStream()); outStream.writeInt(ProtocolConstants.CHECKAGENT); if (inStream.readInt()!=ProtocolConstants.RESPONSE_PROCESSING) throw new Exception("Error response from agent"); // read the number of properties being sent int propertyCount = inStream.readInt(); String key, value; for (int i = 0; i < propertyCount; i++) { key = agentid.toString()+"."+inStream.readUTF(); value = inStream.readUTF(); properties.setProperty(key,value); } if (inStream.readInt()!=ProtocolConstants.RESPONSE_FINISHED_OK) { throw new Exception("Error response from agent"); } resultCode = TRUE; } catch (ConnectException e) { resultCode = FALSE; } finally { if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (socket != null) socket.close(); } } else { try { // test if any agents have been defined StringBuffer agenthost = resolveVariable(new StringBuffer("${agent").append(agentid).append(".name}")); StringBuffer agentport = resolveVariable(new StringBuffer("${agent").append(agentid).append(".port}")); resultCode = TRUE; // in eval mode, we set agent properties to use our properties Properties propertiesT = System.getProperties(); String key, value; for (Enumeration e = propertiesT.propertyNames() ; e.hasMoreElements() ;) { key = e.nextElement().toString(); value = propertiesT.getProperty(key); key = agentid.toString()+"."+key; properties.setProperty(key,value); } } catch (Throwable t) { // no agents have been defined resultCode = FALSE; } } properties.put(result.toString(), resultCode); printStream.println("checkagent reported "+resultCode); } catch (Exception e) { printError(CHECKAGENT_NODE,"invalid checkagent node ("+e.toString()+")"); } } /** * This tag will loop all nested tasks until the while condition evaluates to true.<br> e.g. <loop<br> name="i"<br> start="0"<br> end="5"<br> inc="1"<br> echo message="The current value is ${i}"/><br> loop/><br> <br> Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attri... [truncated message content] |
From: Web H. <web...@us...> - 2004-05-04 13:36:32
|
Update of /cvsroot/qat/QAT/src/qat/agent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20906/src/qat/agent Modified Files: AgentThread.java Log Message: Index: AgentThread.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/agent/AgentThread.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AgentThread.java 15 Sep 2003 10:47:20 -0000 1.5 --- AgentThread.java 4 May 2004 13:35:48 -0000 1.6 *************** *** 431,436 **** finally { test = null; - return status; } } --- 431,436 ---- finally { test = null; } + return status; } |
From: Web H. <web...@us...> - 2004-05-04 13:36:32
|
Update of /cvsroot/qat/QAT/doc/documentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20906/doc/documentation Modified Files: QASHSyntax.html Log Message: Index: QASHSyntax.html =================================================================== RCS file: /cvsroot/qat/QAT/doc/documentation/QASHSyntax.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** QASHSyntax.html 29 Jan 2004 09:16:51 -0000 1.4 --- QASHSyntax.html 4 May 2004 13:35:45 -0000 1.5 *************** *** 9,16 **** <title>QASH Syntax Specification</title> </head> ! <body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#551a8b" ! alink="#ff0000"> <table cols="1" ! style="width: 100%; background-color: rgb(102, 102, 153); font-family: helvetica,arial,sans-serif;" nosave=""> <tbody> --- 9,16 ---- <title>QASH Syntax Specification</title> </head> ! <body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#FF0000" ! alink="#ffff00"> <table cols="1" ! style="width: 100%; background-color: rgb(188, 199, 167); font-family: helvetica,arial,sans-serif;" nosave=""> <tbody> *************** *** 27,31 **** </p> <p style="font-family: helvetica,arial,sans-serif;">Quick links: ! <table style="background-color: rgb(204, 204, 204);" nosave="" border="1"> <tbody> --- 27,31 ---- </p> <p style="font-family: helvetica,arial,sans-serif;">Quick links: ! <table style="background-color: rgb(188, 199, 167);" nosave="" border="1"> <tbody> |
From: Web H. <web...@us...> - 2004-05-04 13:36:29
|
Update of /cvsroot/qat/QAT/src/qat/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20906/src/qat/gui Modified Files: AgentConsole.java DiscoveryProbe.java Log Message: Index: DiscoveryProbe.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/DiscoveryProbe.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DiscoveryProbe.java 11 Feb 2002 15:42:38 -0000 1.2 --- DiscoveryProbe.java 4 May 2004 13:35:49 -0000 1.3 *************** *** 11,78 **** public class DiscoveryProbe { ! private static final int BUFFSIZE = 255; private MulticastSocket socket; ! private InetAddress group; ! private byte buffer[] = new byte[BUFFSIZE]; ! public DiscoveryProbe () { ! try { ! group = InetAddress.getByName(Common.MultiCastGroup); ! socket = new MulticastSocket(); ! socket.joinGroup(group); ! socket.setSoTimeout(Common.TimeToDiscover); ! socket.setTimeToLive(Common.TimeToLive); ! } ! catch(Exception e) { ! e.printStackTrace(); ! } } ! public ArrayList getResponse() { ! ArrayList response = new ArrayList(); ! DatagramPacket pingPacket = new DatagramPacket(buffer, ! Common.DiscoveryProbeString.length(), ! group, ! Common.MultiCastPort); ! try { ! // send the broadcast ping ! for (int i = 0; i < Common.DiscoveryProbeString.length(); i++) ! buffer[i] = (byte)Common.DiscoveryProbeString.charAt(i); ! socket.send(pingPacket); ! // read the responses now ! DatagramPacket replyPacket = new DatagramPacket(buffer, ! BUFFSIZE, ! group, ! Common.MultiCastPort); ! while (1 < 2) { ! clearBytes(replyPacket.getData()); ! replyPacket.setLength(BUFFSIZE); ! socket.receive(replyPacket); ! response.add(new String(replyPacket.getData())); ! Thread.yield(); ! } ! } ! catch (java.io.InterruptedIOException ex) { ! // normal - we don't block waiting for responses after 5 seconds ! } ! catch (java.io.IOException e) { ! e.printStackTrace(); ! } ! finally { ! try { ! socket.leaveGroup(group); ! socket.close(); ! } ! catch (Throwable t) { ! } ! return response; ! } } ! private void clearBytes(byte buff[]) { ! for (int i = 0; i < buff.length; i++) ! buff[i] = 0; ! } } --- 11,78 ---- public class DiscoveryProbe { ! private static final int BUFFSIZE = 255; private MulticastSocket socket; ! private InetAddress group; ! private byte buffer[] = new byte[BUFFSIZE]; ! public DiscoveryProbe () { ! try { ! group = InetAddress.getByName(Common.MultiCastGroup); ! socket = new MulticastSocket(); ! socket.joinGroup(group); ! socket.setSoTimeout(Common.TimeToDiscover); ! socket.setTimeToLive(Common.TimeToLive); ! } ! catch(Exception e) { ! e.printStackTrace(); ! } } ! public ArrayList getResponse() { ! ArrayList response = new ArrayList(); ! DatagramPacket pingPacket = new DatagramPacket(buffer, ! Common.DiscoveryProbeString.length(), ! group, ! Common.MultiCastPort); ! try { ! // send the broadcast ping ! for (int i = 0; i < Common.DiscoveryProbeString.length(); i++) ! buffer[i] = (byte)Common.DiscoveryProbeString.charAt(i); ! socket.send(pingPacket); ! // read the responses now ! DatagramPacket replyPacket = new DatagramPacket(buffer, ! BUFFSIZE, ! group, ! Common.MultiCastPort); ! while (1 < 2) { ! clearBytes(replyPacket.getData()); ! replyPacket.setLength(BUFFSIZE); ! socket.receive(replyPacket); ! response.add(new String(replyPacket.getData())); ! Thread.yield(); ! } ! } ! catch (java.io.InterruptedIOException ex) { ! // normal - we don't block waiting for responses after 5 seconds ! } ! catch (java.io.IOException e) { ! e.printStackTrace(); ! } ! finally { ! try { ! socket.leaveGroup(group); ! socket.close(); ! } ! catch (Throwable t) { ! } } + return response; + } ! private void clearBytes(byte buff[]) { ! for (int i = 0; i < buff.length; i++) ! buff[i] = 0; ! } } Index: AgentConsole.java =================================================================== RCS file: /cvsroot/qat/QAT/src/qat/gui/AgentConsole.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AgentConsole.java 27 May 2003 11:37:14 -0000 1.5 --- AgentConsole.java 4 May 2004 13:35:48 -0000 1.6 *************** *** 210,217 **** try {if (outStream != null) outStream.close();}catch (IOException e) {results.add(e.toString());} try {if (socket != null) socket.close();}catch (IOException e) {results.add(e.toString());} - Object resultsArray[] = results.toArray(); - Arrays.sort(resultsArray); - return resultsArray; } } --- 210,217 ---- try {if (outStream != null) outStream.close();}catch (IOException e) {results.add(e.toString());} try {if (socket != null) socket.close();}catch (IOException e) {results.add(e.toString());} } + Object resultsArray[] = results.toArray(); + Arrays.sort(resultsArray); + return resultsArray; } |
From: <web...@pr...> - 2004-01-31 11:04:05
|
Update of /cvsroot/qat/QAT/doc/mainmenu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22218/doc/mainmenu Removed Files: empty.html main_menu.html Log Message: Latest changes --- empty.html DELETED --- --- main_menu.html DELETED --- |
From: <web...@pr...> - 2004-01-31 05:02:41
|
Update of /cvsroot/qat/QAT/doc/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26108/doc/images Modified Files: title.png Log Message: Latest changes Index: title.png =================================================================== RCS file: /cvsroot/qat/QAT/doc/images/title.png,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsq8Q1KT and /tmp/cvs5NskX2 differ |
From: <web...@pr...> - 2004-01-31 04:05:33
|
Update of /cvsroot/qat/QAT/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21716/doc Modified Files: left_frame.html Log Message: Latest changes Index: left_frame.html =================================================================== RCS file: /cvsroot/qat/QAT/doc/left_frame.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** left_frame.html 26 Jan 2004 16:26:38 -0000 1.1 --- left_frame.html 29 Jan 2004 08:48:04 -0000 1.2 *************** *** 28,32 **** <td align="right"> <a ! href="home.html" class="links" target="content">home</a> --- 28,32 ---- <td align="right"> <a ! href="information/content.html" class="links" target="content">home</a> *************** *** 64,68 **** <br> <a ! href="contact.html" class="links" target="content">contact</a> --- 64,68 ---- <br> <a ! href="contact/content.html" class="links" target="content">contact</a> |
From: <web...@pr...> - 2004-01-31 02:40:10
|
Update of /cvsroot/qat/QAT/doc/documentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26108/doc/documentation Modified Files: FAQ.html QASHSyntax.html QuickStartGuide.html ReleaseHistory.html UserGuide.html Log Message: Latest changes Index: FAQ.html =================================================================== RCS file: /cvsroot/qat/QAT/doc/documentation/FAQ.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FAQ.html 23 Jan 2003 12:23:28 -0000 1.1 --- FAQ.html 29 Jan 2004 09:16:49 -0000 1.2 *************** *** 1,65 **** ! <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en"> ! <html> ! <head> ! <meta http-equiv="Content-Type" ! content="text/html; charset=iso-8859-1"> ! <meta name="GENERATOR" ! content="Mozilla/4.7 [en] (X11; I; SunOS 5.9 sun4u) [Netscape]"> ! <meta name="Author" content="webhiker"> ! <title>Overview</title> ! </head> ! <body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#551a8b" ! alink="#ff0000"> ! <h1> </h1> ! <table cols="1" ! style="width: 100%; background-color: rgb(102, 102, 153);" nosave=""> ! <tbody> ! <tr> ! <td> ! <h1>Overview</h1> ! </td> ! </tr> ! </tbody> ! </table> ! <br> ! <table cols="1" style="width: 100%; background-color: rgb(255, 204, 0);" ! nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave=""> ! <h3>Is it only for distributed testing?</h3> ! </td> ! </tr> ! </tbody> ! </table> ! <h3></h3> ! Not necessarily, but it's main feature is being able to run a test on ! many different architectures with minimal configuration. For example, ! if you follow the Quick Start Guide you will in five minutes, be able ! to run the same test on NT, Solaris-Intel or Solaris-Sparc without ! modifying the test itself. <br> ! Furthermore, no installation of any kind is required, since the test is ! itself sent to the machine which is running it. <br> ! If your product runs only on one architecture, there are many better ! products available for this type of testing. <br> ! <br> ! <table cols="1" style="width: 100%; background-color: rgb(255, 204, 0);" ! nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave=""> ! <h3>Do my tests have to be written in Java?</h3> ! </td> ! </tr> ! </tbody> ! </table> ! <br> ! The test examples provided with the distribution zip file are written ! in Java, but they may be written in any binary form you wish. <br> ! You are responsible however, for ensuring a binary version exists for ! each agent architecture you want to run the test on. For example, if you ! wish to run your tests on x86 and Sparc architecture, you will need ! provide binary versions of your tests in a format able to run on both ! of these architectures. ! </body> ! </html> --- 1,66 ---- ! <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en"> ! <html> ! <head> ! <meta content="text/html; charset=iso-8859-1" ! http-equiv="Content-Type"> ! <meta content="Mozilla/4.7 [en] (X11; I; SunOS 5.9 sun4u) [Netscape]" ! name="GENERATOR"> ! <meta content="webhiker" name="Author"> ! <title>Overview</title> ! </head> ! <body alink="#ff0000" vlink="#551a8b" link="#0000ee" bgcolor="#ffffff" ! text="#000000"> ! <h1> </h1> ! <table nosave="" ! style="width: 100%; background-color: rgb(102, 102, 153);" cols="1"> ! <tbody> ! <tr> ! <td> ! <h1 style="background-color: rgb(188, 199, 167);">Overview</h1> ! </td> ! </tr> ! </tbody> ! </table> ! <br> ! <table nosave="" ! style="width: 100%; background-color: rgb(255, 204, 0);" cols="1"> ! <tbody> ! <tr nosave=""> ! <td nosave=""> ! <h3>Is it only for distributed testing?</h3> ! </td> ! </tr> ! </tbody> ! </table> ! <h3></h3> ! Not necessarily, but it's main feature is being able to run a test on ! many different architectures with minimal configuration. For example, ! if you follow the Quick Start Guide you will in five minutes, be able ! to run the same test on NT, Solaris-Intel or Solaris-Sparc without ! modifying the test itself. <br> ! Furthermore, no installation of any kind is required, since the test is ! itself sent to the machine which is running it. <br> ! If your product runs only on one architecture, there are many better ! products available for this type of testing. <br> ! <br> ! <table nosave="" ! style="width: 100%; background-color: rgb(255, 204, 0);" cols="1"> ! <tbody> ! <tr nosave=""> ! <td nosave=""> ! <h3>Do my tests have to be written in Java?</h3> ! </td> ! </tr> ! </tbody> ! </table> ! <br> ! The test examples provided with the distribution zip file are written ! in Java, but they may be written in any binary form you wish. <br> ! You are responsible however, for ensuring a binary version exists for ! each agent architecture you want to run the test on. For example, if ! you ! wish to run your tests on x86 and Sparc architecture, you will need ! provide binary versions of your tests in a format able to run on both ! of these architectures. ! </body> ! </html> Index: QASHSyntax.html =================================================================== RCS file: /cvsroot/qat/QAT/doc/documentation/QASHSyntax.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QASHSyntax.html 15 Dec 2003 09:09:52 -0000 1.3 --- QASHSyntax.html 29 Jan 2004 09:16:51 -0000 1.4 *************** *** 2,21 **** <html> <head> ! <meta content="text/html; charset=iso-8859-1" ! http-equiv="Content-Type"> ! <meta content="Mozilla/4.7 [en] (X11; I; SunOS 5.9 sun4u) [Netscape]" ! name="GENERATOR"> ! <meta content="webhiker" name="Author"> <title>QASH Syntax Specification</title> </head> ! <body alink="#ff0000" vlink="#551a8b" link="#0000ee" bgcolor="#ffffff" ! text="#000000"> ! <table nosave="" style="width: 100%; background-color: rgb(102, 102, 153); font-family: helvetica,arial,sans-serif;" ! cols="1"> <tbody> <tr> <td> ! <h1> QASH Syntax 2.7.x</h1> </td> </tr> --- 2,22 ---- <html> <head> ! <meta http-equiv="Content-Type" ! content="text/html; charset=iso-8859-1"> ! <meta name="GENERATOR" ! content="Mozilla/4.7 [en] (X11; I; SunOS 5.9 sun4u) [Netscape]"> ! <meta name="Author" content="webhiker"> <title>QASH Syntax Specification</title> </head> ! <body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#551a8b" ! alink="#ff0000"> ! <table cols="1" style="width: 100%; background-color: rgb(102, 102, 153); font-family: helvetica,arial,sans-serif;" ! nosave=""> <tbody> <tr> <td> ! <h1 style="background-color: rgb(188, 199, 167);"> QASH Syntax ! 2.7.x</h1> </td> </tr> *************** *** 26,31 **** </p> <p style="font-family: helvetica,arial,sans-serif;">Quick links: ! <table border="1" nosave="" ! style="background-color: rgb(204, 204, 204);"> <tbody> <tr nosave=""> --- 27,32 ---- </p> <p style="font-family: helvetica,arial,sans-serif;">Quick links: ! <table style="background-color: rgb(204, 204, 204);" nosave="" ! border="1"> <tbody> <tr nosave=""> *************** *** 234,238 **** <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr nosave=""> --- 235,239 ---- <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr nosave=""> *************** *** 254,259 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr nosave=""> --- 255,260 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr nosave=""> *************** *** 268,273 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! border="1"> <tbody> <tr nosave=""> --- 269,274 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table border="1" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr nosave=""> *************** *** 328,332 **** assignment operators are allowed : <br> ! <table nosave="" border="1"> <tbody> <tr> --- 329,333 ---- assignment operators are allowed : <br> ! <table border="1" nosave=""> <tbody> <tr> *************** *** 371,375 **** <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 372,376 ---- <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 409,418 **** style="font-family: helvetica,arial,sans-serif;">TEMP2</b><span style="font-family: helvetica,arial,sans-serif;"> will now contain the ! value </span><font style="font-family: helvetica,arial,sans-serif;" ! color="#006600">"Test String"</font><span style="font-family: helvetica,arial,sans-serif;"> and </span><b style="font-family: helvetica,arial,sans-serif;">TEMP3</b><span style="font-family: helvetica,arial,sans-serif;"> will contain </span><font ! style="font-family: helvetica,arial,sans-serif;" color="#006600">"Test String 2"</font><span style="font-family: helvetica,arial,sans-serif;"> </span><br style="font-family: helvetica,arial,sans-serif;"> --- 410,419 ---- style="font-family: helvetica,arial,sans-serif;">TEMP2</b><span style="font-family: helvetica,arial,sans-serif;"> will now contain the ! value </span><font color="#006600" ! style="font-family: helvetica,arial,sans-serif;">"Test String"</font><span style="font-family: helvetica,arial,sans-serif;"> and </span><b style="font-family: helvetica,arial,sans-serif;">TEMP3</b><span style="font-family: helvetica,arial,sans-serif;"> will contain </span><font ! color="#006600" style="font-family: helvetica,arial,sans-serif;">"Test String 2"</font><span style="font-family: helvetica,arial,sans-serif;"> </span><br style="font-family: helvetica,arial,sans-serif;"> *************** *** 432,437 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 433,438 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 475,479 **** <span style="font-family: helvetica,arial,sans-serif;"> The boolean expression may use any of the boolean operators listed in the section </span><a ! style="font-family: helvetica,arial,sans-serif;" href="#OPERATORS">OPERATORS</a><span style="font-family: helvetica,arial,sans-serif;"> but no assignment may --- 476,480 ---- <span style="font-family: helvetica,arial,sans-serif;"> The boolean expression may use any of the boolean operators listed in the section </span><a ! href="#OPERATORS" style="font-family: helvetica,arial,sans-serif;">OPERATORS</a><span style="font-family: helvetica,arial,sans-serif;"> but no assignment may *************** *** 488,493 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 489,494 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 529,534 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 530,535 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 565,569 **** to simplify the explanations. <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 566,570 ---- to simplify the explanations. <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 589,594 **** <b><font color="#009900">qat.test.author = "webhiker"</font></b> <br> <b><font color="#009900">qat.test.buginfo = ""</font></b></blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 590,595 ---- <b><font color="#009900">qat.test.author = "webhiker"</font></b> <br> <b><font color="#009900">qat.test.buginfo = ""</font></b></blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 613,618 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! border="1"> <tbody> <tr> --- 614,619 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table border="1" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 669,674 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 670,675 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 704,709 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 705,710 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 745,754 **** specified by </span><b style="font-family: helvetica,arial,sans-serif;">WORK_DIR</b><span style="font-family: helvetica,arial,sans-serif;">does not exist prior ! to the call to </span><a ! style="font-family: helvetica,arial,sans-serif;" href="#SETAGENT">SETAGENT</a><span style="font-family: helvetica,arial,sans-serif;">, then it will be automatically created. When the corresponding DELAGENT command is called, the entire directory and it's contents will be deleted if the </span><a ! style="font-family: helvetica,arial,sans-serif;" href="#AUTOCLEAN_ON">AUTOCLEAN_ON</a><span style="font-family: helvetica,arial,sans-serif;"> command was called. </span><br style="font-family: helvetica,arial,sans-serif;"> --- 746,755 ---- specified by </span><b style="font-family: helvetica,arial,sans-serif;">WORK_DIR</b><span style="font-family: helvetica,arial,sans-serif;">does not exist prior ! to the call to </span><a href="#SETAGENT" ! style="font-family: helvetica,arial,sans-serif;">SETAGENT</a><span style="font-family: helvetica,arial,sans-serif;">, then it will be automatically created. When the corresponding DELAGENT command is called, the entire directory and it's contents will be deleted if the </span><a ! href="#AUTOCLEAN_ON" style="font-family: helvetica,arial,sans-serif;">AUTOCLEAN_ON</a><span style="font-family: helvetica,arial,sans-serif;"> command was called. </span><br style="font-family: helvetica,arial,sans-serif;"> *************** *** 756,761 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 757,762 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 786,791 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 787,792 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 804,809 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 805,810 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 820,828 **** the result will be stored in a variable of this name <br> <b>KEY</b>- the name of the static variable to be retrieved</blockquote> ! <hr style="font-family: helvetica,arial,sans-serif;" width="100%"> <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 821,829 ---- the result will be stored in a variable of this name <br> <b>KEY</b>- the name of the static variable to be retrieved</blockquote> ! <hr width="100%" style="font-family: helvetica,arial,sans-serif;"> <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 858,863 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 859,864 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 905,910 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 906,911 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 926,931 **** <b>VALUE</b> - the value of the property to be deleted. Not neccesary to use this form.</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 927,932 ---- <b>VALUE</b> - the value of the property to be deleted. Not neccesary to use this form.</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 954,959 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 955,960 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 993,998 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 994,999 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1018,1023 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1019,1024 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1037,1042 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1038,1043 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1062,1067 **** <blockquote style="font-family: helvetica,arial,sans-serif;"><b>CMD_ID </b>- the command identifier of the process who's trace you wish to retrieve.</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1063,1068 ---- <blockquote style="font-family: helvetica,arial,sans-serif;"><b>CMD_ID </b>- the command identifier of the process who's trace you wish to retrieve.</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1086,1091 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1087,1092 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1103,1108 **** href="#ZIPSEND">ZIPSEND </a>command</blockquote> <br style="font-family: helvetica,arial,sans-serif;"> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> --- 1104,1109 ---- href="#ZIPSEND">ZIPSEND </a>command</blockquote> <br style="font-family: helvetica,arial,sans-serif;"> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> *************** *** 1121,1126 **** </p> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1122,1127 ---- </p> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1143,1148 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1144,1149 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1162,1167 **** <br> <b>RESULT </b>- the status of the request (0 = succeeded, 1 = failed)</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1163,1168 ---- <br> <b>RESULT </b>- the status of the request (0 = succeeded, 1 = failed)</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1187,1192 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1188,1193 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1204,1209 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1205,1210 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1229,1234 **** <b><font color="#009900">PRINT "Agent name :"+AGENT+" Agent port:"+PORT</font></b></blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1230,1235 ---- <b><font color="#009900">PRINT "Agent name :"+AGENT+" Agent port:"+PORT</font></b></blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1249,1253 **** directory. <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1250,1254 ---- directory. <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 1266,1270 **** <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1267,1271 ---- <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 1282,1286 **** <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1283,1287 ---- <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 1311,1316 **** style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1312,1317 ---- style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1332,1337 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1333,1338 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1353,1358 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1354,1359 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1374,1379 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1375,1380 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1392,1397 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1393,1398 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1408,1413 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1409,1414 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1450,1455 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1451,1456 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1466,1471 **** <blockquote style="font-family: helvetica,arial,sans-serif;"><b>FILE_PATH</b> - the path to the file/directory to be deleted, relative to the harness</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1467,1472 ---- <blockquote style="font-family: helvetica,arial,sans-serif;"><b>FILE_PATH</b> - the path to the file/directory to be deleted, relative to the harness</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1487,1492 **** <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1488,1493 ---- <br style="font-family: helvetica,arial,sans-serif;"> <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1510,1515 **** color="#009900">54324554</font></b></p> </blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1511,1516 ---- color="#009900">54324554</font></b></p> </blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1546,1551 **** <b><font color="#009900">Hello World</font></b></p> </blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1547,1552 ---- <b><font color="#009900">Hello World</font></b></p> </blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1561,1565 **** href="#FUNCTION%28FUNCTION_NAME%29">FUNCTION(...) </a>for details. <br> ! <table nosave="" bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1562,1566 ---- href="#FUNCTION%28FUNCTION_NAME%29">FUNCTION(...) </a>for details. <br> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave=""> <tbody> <tr> *************** *** 1583,1588 **** exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1584,1589 ---- exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1605,1610 **** exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1606,1611 ---- exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> *************** *** 1627,1632 **** exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table style="font-family: helvetica,arial,sans-serif;" nosave="" ! bgcolor="#ffcc00" width="100%" cols="1"> <tbody> <tr> --- 1628,1633 ---- exists, 1 indicates the string does exist. <br> <b>STRING</b>- the string to look for.</blockquote> ! <table cols="1" width="100%" bgcolor="#ffcc00" nosave="" ! style="font-family: helvetica,arial,sans-serif;"> <tbody> <tr> Index: QuickStartGuide.html =================================================================== RCS file: /cvsroot/qat/QAT/doc/documentation/QuickStartGuide.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QuickStartGuide.html 23 Jan 2003 16:11:00 -0000 1.1 --- QuickStartGuide.html 29 Jan 2004 09:16:53 -0000 1.2 *************** *** 1,450 **** ! <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ! <html> ! <head> ! <meta http-equiv="Content-Type" ! content="text/html; charset=iso-8859-1"> ! <meta name="GENERATOR" ! content="Mozilla/4.7 [en] (X11; I; SunOS 5.9 sun4u) [Netscape]"> ! <meta name="Author" content="webhiker"> ! <meta name="Description" content="Quick Start Guide for QA Tester"> ! <title>Quick Start Guide</title> ! </head> ! <body> ! <table cols="1" ! style="width: 100%; background-color: rgb(102, 102, 153); font-family: helvetica,arial,sans-serif;" ! nosave=""> ! <tbody> ! <tr> ! <td> ! <h1>Quick start guide</h1> ! </td> ! </tr> ! </tbody> ! </table> ! <br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;"> This is a work ! in progress. For full documentation, please see the </span><a ! href="https://sourceforge.net/project/showfiles.php?group_id=28766" ! style="font-family: helvetica,arial,sans-serif;">distribution</a><span ! style="font-family: helvetica,arial,sans-serif;"> zip file contents. </span> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Introduction"></a>Introduction</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> This tool was ! developed specifically for testing products running across a wide ! variety of hardware and software platforms. Since it is completely ! written in Java, any machine capable of supporting a J</span><i ! style="font-family: helvetica,arial,sans-serif;">ava Virtual Machine</i><span ! style="font-family: helvetica,arial,sans-serif;"> (JVM) can be used. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The QAT tool can ! be divided into two main sections, the Agent, responsible for actually ! running each test or group of tests, and the Harness, which is ! responsible for test selection, management, result and agent ! co-ordination. All that is required to run a test on a given machine, ! is an Agent running in a compatible JVM. </span> ! <p style="font-family: helvetica,arial,sans-serif;">This document ! covers the following areas <br> ! </p> ! <ul style="font-family: helvetica,arial,sans-serif;"> ! <li> <a href="#System%20Requirements">System requirements</a></li> ! <li> <a href="#Environment%20settings">Environment settings</a></li> ! <li> <a href="#Starting%20an%20Agent">Starting an agent</a></li> ! <li> <a href="#Starting%20the%20QAT%20Harness">Starting the harness</a></li> ! <li> <a ! href="#Connecting%20to%20a%20running%20instance%20of%20QAT%20via%20a%20browser">Connecting ! to a running instance of QAT via a browser</a></li> ! <li> <a href="#Configuring%20GUI%20Project%20Properties">Configuring ! GUI project properties</a></li> ! <li> <a href="#Running%20tests%20via%20the%20commandline%20interface">Running ! tests via the command line</a></li> ! </ul> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="System Requirements"></a>System Requirements</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> The Agent ! portion of the QAT tool will run on any JVM supporting Java ! Specification 1.1.x or later. If you cannot run this version of the ! JVM, you may compile a binary version of the agent from the sources, ! for your particular platform. It is currently written as a POSIX ! compliant bundle of C++ classes, and has been validated on Chorus and ! Solaris. </span><br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">Since the result ! reporting functions of the Agent are file based, a file system is ! mandatory. </span><br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The Harness ! requires at least Java 2, and is currently maintained on JDK1.3 FCS. </span> ! <p style="font-family: helvetica,arial,sans-serif;">Since the harness ! is a GUI application, some X-window or Window server is required, ! unless you choose to use only the command line interface to the ! harness. <br> ! Whether the harness runs on NT or Solaris or any other platform (or all ! of them) depends on how portably the tests are written. <br> ! </p> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Environment settings"></a>Environment settings</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> Ensure the jar ! file </span><b style="font-family: helvetica,arial,sans-serif;">qat.jar</b><span ! style="font-family: helvetica,arial,sans-serif;"> is visible via the </span><b ! style="font-family: helvetica,arial,sans-serif;">CLASSPATH </b><span ! style="font-family: helvetica,arial,sans-serif;">environment variable (</span><b ! style="font-family: helvetica,arial,sans-serif;"><i>setenv CLASSPATH ! ./qat.jar </i></b><span ! style="font-family: helvetica,arial,sans-serif;">), or directly upon ! invoking the </span><b style="font-family: helvetica,arial,sans-serif;">JVM</b><span ! style="font-family: helvetica,arial,sans-serif;"> via the "-classpath" ! option. </span><br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <blockquote style="font-family: helvetica,arial,sans-serif;">e.g.</blockquote> ! <blockquote style="font-family: helvetica,arial,sans-serif;"> ! <blockquote><b><i>java -classpath ./qat.jar ClassName</i></b></blockquote> ! </blockquote> ! <blockquote style="font-family: helvetica,arial,sans-serif;">or ! <blockquote><b><i>setenv CLASSPATH /home/user/qat.jar</i></b></blockquote> ! </blockquote> ! <blockquote style="font-family: helvetica,arial,sans-serif;"> ! <blockquote><b><i>java <ClassName></i></b></blockquote> ! If you are using Windows and have installed Java 1.2, you can double ! click the qat.jar file to directly launch the QAT GUI interface, or via ! commandline using <br> ! the form : <b><i>java -jar qat.jar</i></b></blockquote> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Starting an Agent"></a>Starting an Agent</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> You can start an ! agent by typing </span> ! <blockquote style="font-family: helvetica,arial,sans-serif;"><b>java ! Agent </b><i>port number</i>> [<i>debug level</i>] ! <p>where </p> ! <blockquote><i>port number </i>= the port which will be used for ! communicating / transferring files to and from the harness <br> ! d<i>ebug level </i>= the debug level (0..10) to control which, if any, ! messages are sent to the <i>stdout</i> and <i>stderr</i> streams of the ! Agent (default value is 0)</blockquote> ! </blockquote> ! <span style="font-family: helvetica,arial,sans-serif;"> Any temporary or ! other such files created by the agent will be placed in the directory </span><b ! style="font-family: helvetica,arial,sans-serif;"><i>{user.home}/.qat/agent</i></b><span ! style="font-family: helvetica,arial,sans-serif;">. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">Repeat this ! process for as many machines and agents as you require. An example of a ! started agent is shown here: </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <br style="font-family: helvetica,arial,sans-serif;"> ! <img src="images/figure5.png" ! style="font-family: helvetica,arial,sans-serif; width: 451px; height: 195px;" ! title="" alt="images/figure5.png"> ! <p style="font-family: helvetica,arial,sans-serif;">To kill the agent, ! simply type <i>Control-C</i> in the terminal window to send a KILL ! signal to the <b>JVM</b>. </p> ! <p style="font-family: helvetica,arial,sans-serif;">Note: Each agent ! requires a unique port number, but one or all of the agents may be run ! on the same machine as the harness. <br> ! Each agent, however, has to be run in a separate <b>JVM</b>. <br> ! Furthermore, one agent may be used by as many harnesses as required, so ! instead of two separate agents, you may configure your test to use the ! same agent. <br> ! In this case, be sure to ensure each agent uses a unique temporary ! directory to store it's files, by making use of the RANDOM script ! command when you call SETAGENT to prevent agents messing with ! each others files. <br> ! No windowing system is required by the agent. </p> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Starting the QAT Harness"></a>Starting the QAT Harness</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> You can start ! the GUI harness by typing </span> ! <blockquote style="font-family: helvetica,arial,sans-serif;"><b>java ! QAT [language]</b></blockquote> ! <span style="font-family: helvetica,arial,sans-serif;"> The language ! option currently only supports French (</span><b ! style="font-family: helvetica,arial,sans-serif;">-FR</b><span ! style="font-family: helvetica,arial,sans-serif;">) and Afrikaans (</span><b ! style="font-family: helvetica,arial,sans-serif;">-AF)</b><span ! style="font-family: helvetica,arial,sans-serif;">, and if omitted, ! defaults to English. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">If this is the ! first time you are running the tool, you will get some warnings that ! previous settings file have not been found, but you may ignore them, ! they will be created for you. (default.prj and default.ser). Each time ! you exit and restart the Harness, your previous project settings will ! be restored from these files. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">In addition, ! screen size and placement of the QAT gui will be saved in the </span><i ! style="font-family: helvetica,arial,sans-serif;">session.properties</i><span ! style="font-family: helvetica,arial,sans-serif;"> file. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">These settings ! are stored in the {user.home}/.qat/harness directory. </span> ! <p style="font-family: helvetica,arial,sans-serif;">You will now see ! the screen displayed in <a href="#Figure%201">Figure 1.</a> <br> ! <br> ! ! <table border="1" nosave=""> ! <tbody> ! <tr> ! <td><a name="Figure 1"></a><img src="images/figure1.png" title="" ! alt="images/figure1.png" style="width: 829px; height: 630px;"></td> ! </tr> ! </tbody><caption align="bottom">Figure 1<br> ! <br> ! </caption> ! </table> ! <br> ! <br> ! </p> ! <p style="font-family: helvetica,arial,sans-serif;">Let's use the ! example tests provided with this tool in the examples directory, and ! set up some tests to run on Solaris and NT. <br> ! There are three steps to set up the harness to run the examples. <br> ! </p> ! <h4 style="font-family: helvetica,arial,sans-serif;"> 1)Define our ! agents.</h4> ! <blockquote style="font-family: helvetica,arial,sans-serif;">From the ! system menu, select <b>Edit</b> -> <b>Agent Settings.</b> <br> ! This will display the window displayed in <a href="#Figure%202">Figure ! 2</a>, with which you can graphically configure your agents. <br> ! Initially there are obviously none, so select the "<b>Add agent</b>" ! option, and fill in the machine name and port number. The port number is ! the same value you used when starting the agent as outlined in the above ! section <a href="#Starting%20an%20Agent">Starting an Agent</a>. <br> ! If the agent is currently running, you can click on the "<b>Detect"</b> ! button to automatically fill in the "<b>Architecture</b>" and "<b>Operating ! System</b>" fields. <br> ! The "<b>Agent number</b>" is used within your test scripts to ! differentiate between the different agents. <br> ! Any agents defined here are accessible in the .qash files as <b>agent1.name</b>,<b>agent2.port</b> ! etc. This will be covered in more detail later. <br> ! ! <table border="1" nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave=""><a name="Figure 2"></a><img ! src="images/figure2.png" title="" alt="images/figure2.png" ! style="width: 619px; height: 505px;"></td> ! </tr> ! </tbody><caption align="bottom">Figure 2<br> ! <br> ! </caption> ! </table> ! </blockquote> ! <h4 style="font-family: helvetica,arial,sans-serif;"> 2)Define project ! settings</h4> ! <blockquote style="font-family: helvetica,arial,sans-serif;">Now we ! have our agents defined, we need to set up our project for the first ! time. <br> ! From the system menu, select Edit -> Edit Project to bring up the ! Project settings window. <br> ! You will see a blank text area - this is where you define specific ! properties for your test suite. <br> ! ! <p>Ensure the following two properties are defined and correct for ! your particular system :</p> ! </blockquote> ! <center style="font-family: helvetica,arial,sans-serif;"> ! <table border="1" bgcolor="#cccccc" nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave="">JAVAHOME_SOLARIS=/usr/java1.2 <br> ! JAVAHOME_NT=c:\jdk1.2.1</td> ! </tr> ! </tbody> ! </table> ! </center> ! <p style="font-family: helvetica,arial,sans-serif;">So your project ! properties should look something like <a href="#Figure%203">Figure 3</a> ! : <br> ! ! <table border="1" nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave=""><a name="Figure 3"></a><img src="images/figure3.png" ! title="" alt="images/figure3.png" style="width: 725px; height: 433px;"></td> ! </tr> ! </tbody><caption align="bottom">Figure 3<br> ! <br> ! </caption> ! </table> ! </p> ! <h4 style="font-family: helvetica,arial,sans-serif;"> 3)Select test ! directory</h4> ! <span style="font-family: helvetica,arial,sans-serif;"> Next, we tell ! the harness where to look for the .qash files which constitute our test ! suite. </span><br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">Click on the tab ! "Project Settings" (see </span><a href="#Figure%203" ! style="font-family: helvetica,arial,sans-serif;">Figure 3</a><span ! style="font-family: helvetica,arial,sans-serif;">), and you will see ! an entry for selecting the test directory path. Ensure this points to ! the </span><i style="font-family: helvetica,arial,sans-serif;">{qat_home}/examples</i><span ! style="font-family: helvetica,arial,sans-serif;"> directory, and then ! click the OK button to start loading the tests. You can also tweak ! various other settings here, such as Look and Feel, custom plugins and ! parsers, but for the moment we just need to point to the examples. </span> ! <p style="font-family: helvetica,arial,sans-serif;">Once selected, ! choose OK to load all the tests in the selected examples directory : </p> ! <p style="font-family: helvetica,arial,sans-serif;"><img ! src="images/figure3a.png" title="" alt="images/figure3a.png" ! style="width: 725px; height: 433px;"> </p> ! <p style="font-family: helvetica,arial,sans-serif;">You should now see ! a tree structure similar to <a href="#Figure%204">Figure 4</a> : <br> ! ! <table border="1" nosave=""> ! <tbody> ! <tr nosave=""> ! <td nosave=""><a name="Figure 4"></a><img src="images/figure4.png" ! title="" alt="images/figure4.png" style="width: 829px; height: 630px;"></td> ! </tr> ! </tbody><caption align="bottom">Figure 4<br> ! <br> ! </caption> ! </table> ! </p> ! <h1 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Running the tests"></a>Running the tests</h1> ! <span style="font-family: helvetica,arial,sans-serif;"> Your harness ! should now be ready to run the example tests, so you may now either ! right click on the test you wish to run, or use the system menu to ! start a test run. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The test(s) ! should run without any problems. If for some reason there are errors, ! consult the console traces (by clicking on the "ParserOutput Viewer" ! tab of the main window) to see what went wrong. For this reason it is ! recommended you start your agents with a debug level of 9 until you are ! sure your settings are all correct. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">Exiting the ! Harness will save all you current settings, and they will be resumed on ! your next setting. </span> ! <p style="font-family: helvetica,arial,sans-serif;">To change which ! agents to use, simply edit the relevant agents from the system menu ! "Edit"->"Edit agents" until you have the configuration you want. <br> ! In this way you can build up different test scenarios using the project ! Save As option. </p> ! <p style="font-family: helvetica,arial,sans-serif;">For more details on ! how to use the GUI interface, you should now be ready for the <a ! href="http://qat.sourceforge.net/QASHHarness.html">QAT Harness Manual.</a> <br> ! If you are ready to write your own tests, you can go directly to the <a ! href="http://qat.sourceforge.net/QASHSyntax.html">QASH Syntax page.</a> <br> ! <br> ! </p> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Connecting to a running instance of QAT via a browser"></a>Connecting ! to a running instance of QAT via a web browser</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> It is possible ! to use a standard web browser to connect to a running instance of the ! QAT harness, by pointing your browser to </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <a href="http://localhost:9080/" ! style="font-family: helvetica,arial,sans-serif;">http://localhost:9080</a><span ! style="font-family: helvetica,arial,sans-serif;"> . You may change the ! port used by the Http server by editing the project properties. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">This interface ! gives a limited access to functions of the QAT tool, such as ! starting/stopping tests, as well as viewing live test results. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;"> </span> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Configuring GUI Project Properties"></a>Configuring GUI project ! properties</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> You can ! configure project properties to appears as GUI components in the Edit ! Project Properties window by assigning them with special name prefixes. ! Currently you can make use of TextField, ComboBox and CheckBox ! components. </span><br style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The following ! conventions are used : </span> ! <blockquote style="font-family: helvetica,arial,sans-serif;">This will ! produce a CheckBox called Example1 with default value of unchecked. The ! tooltip text will be set to the complete variable name. ! <blockquote><b>qat.project.guiproperty.checkbox.Example1=false </b> <img ! src="images/guip1.png" title="" alt="images/guip1.png" ! style="width: 322px; height: 126px;"></blockquote> ! <br> ! <br> ! ! <p>This will produce a TextField called Example2 with text containing ! "Hello World". The tooltip text will be set to the complete variable ! name. </p> ! <blockquote><b>qat.project.guiproperty.textfield.Example2=Hello ! World </b><img src="images/guip3.png" title="" ! alt="images/guip3.png" style="width: 123px; height: 43px;"></blockquote> ! <br> ! <br> ! <br> ! ! <p>This will produce a ComboBox called Example3 with selected item ! "a", and possible values of "a" through "g". The tooltip text will be ! set to the complete variable name. </p> ! <blockquote><b>qat.project.guiproperty.combobox.Example3=a</b> <br> ! <b>qat.project.guiproperty.combobox.Example3.values=a,b,c,d,e,f,g </b><img ! src="images/guip2.png" title="" alt="images/guip2.png" ! style="width: 123px; height: 43px;"></blockquote> ! If any GUI properties are detected in the project properties, or added ! by editing the project properties, the next time the project properties ! window is displayed, a new tab will appear displaying by default these ! properties as GUI components. <br> ! If the OK button is selected, the value of the GUI components is ! accepted as the required value, however if the text version tab is ! currently being displayed, the text version of the properties (which ! are still displayed) will be taken and will override any GUI properties.</blockquote> ! <h2 style="font-family: helvetica,arial,sans-serif;"> <a ! name="Running tests via the commandline interface"></a>Running tests ! via the command line interface</h2> ! <span style="font-family: helvetica,arial,sans-serif;"> There are two ! ways to launch tests via the command line interface. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The first way ! uses the QAT gui, but doesn't actually display it, and drives the test ! run according the parameters specified on the commandline. This method ! allows more detailed control over test selection, and allows the test ! run to be archived into html reoprts. </span><br ! style="font-family: helvetica,arial,sans-serif;"> ! <span style="font-family: helvetica,arial,sans-serif;">The second ! method is to launch each test by invoking the QASHParser directly. </span> ! <h4 style="font-family: helvetica,arial,sans-serif;"> Method ! 1(Recommended) :</h4> ! <blockquote style="font-family: helvetica,arial,sans-serif;">java ! -classpath {qat.jar} QAT <b>-cmdline</b> <b>-project</b> ! {projectFileName} [<b>-reportdir</b> {reportDirectory}] [-rescan] [<b>+keyword</b> ! keyword1] [<b>-keyword</b> keyword2] ! <p><b>-cmdline </b>- indicates we want to launch the harness in ! commandline mode only <br> ! <b>-project </b><i>{projectFileName}</i> - mandatory parameter ! specifying the full path to a QAT project file for the specified test ! run <br> ! <b>-reportdir </b><i>{reportDirectory}</i> - optional parameter which ! is the full path to the directory in which to store the generated htm... [truncated message content] |