From bd333cd4becce1bfc0cad6123233af5603163f0f Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Wed, 28 Nov 2007 14:08:48 +0000
Subject: [PATCH] Issue 1131 specify and generate test specification docs from tests
---
opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java | 172 +++++++++++++++++++++++++++++---------------------------
1 files changed, 89 insertions(+), 83 deletions(-)
diff --git a/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java b/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java
index db1b06b..21ff98b 100644
--- a/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java
+++ b/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java
@@ -28,124 +28,129 @@
import java.lang.*;
import java.util.ArrayList;
-public class WriteXMLFile_xml
-{
+public class WriteXMLFile_xml {
private String group;
- private ArrayData arrayData;
- private ArrayList <String> strIndividualSteps;
- public WriteXMLFile_xml(String inGroup)
- {
+ private ArrayData arrayData;
+
+ private ArrayList<String> strIndividualSteps;
+
+ public WriteXMLFile_xml(String inGroup) {
group = inGroup;
strIndividualSteps = null;
}
- public void MakeXMLFile(ArrayData arrayData, String strDir) throws IOException
- {
+ public void MakeXMLFile(ArrayData arrayData, String strDir)
+ throws IOException {
String strDirName = strDir + "/" + group;
File fileDirName = new File(strDirName);
- if(!fileDirName.isDirectory())
- {
- if(!fileDirName.mkdirs())
- {
- System.out.println("Could not create directory, " + strDirName);
- System.out.println("Exiting.....");
- System.exit(0);
- }
+ if (!fileDirName.isDirectory()) {
+ if (!fileDirName.mkdirs()) {
+ System.out.println("Could not create directory, " + strDirName);
+ System.out.println("Exiting.....");
+ System.exit(0);
+ }
}
String strFilename;
- if(group.indexOf("/") < 0)
- {
- strFilename = strDirName + "/" + group + ".xml";
+ if (group.indexOf("/") < 0) {
+ strFilename = strDirName + "/" + group + ".xml";
+ } else {
+ String tmpStr = new String(group);
+ int index = tmpStr.indexOf("/") + 1;
+ String subStr = tmpStr.substring(index);
+ strFilename = strDirName + "/" + subStr + ".xml";
}
- else
- {
- String tmpStr = new String(group);
- int index = tmpStr.indexOf("/") + 1;
- String subStr = tmpStr.substring(index);
- strFilename = strDirName + "/" + subStr + ".xml";
- }
+
+ //System.out.println("Processing: " + strFilename);
File fileOutput = new File(strFilename);
FileWriter fwOutput = new FileWriter(fileOutput);
- fwOutput.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
- fwOutput.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + group + ".xsl\"?>\n");
- fwOutput.write("<qa xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"no-schema-yet.xsd\">\n\n");
+ fwOutput.write("<?xml version=\"1.0\"?>\n\n");
+
+ fwOutput.write("<qa>\n");
fwOutput.write(" <!-- A section describing each product under test -->\n");
fwOutput.write(" <product name=\"OpenDS\">\n\n");
- fwOutput.write(" <!-- A section describing each testgroup-->\n");
- fwOutput.write(" <testgroup name=\"Functional\">\n");
+ fwOutput.write(" <!-- A section describing each testphase-->\n");
+ fwOutput.write(" <testphase name=\"Functional\">\n\n");
- fwOutput.write(" <groupname>" + arrayData.getGroupName(0) + "</groupname>\n");
- fwOutput.write(" <grouppurpose>" + arrayData.getGroupPurpose(0) + "</grouppurpose>\n");
- fwOutput.write(" <subgroupname>" + arrayData.getSubgroupName(0) + "</subgroupname>\n");
- fwOutput.write(" <category name=\"" + group + "\"/>\n");
- fwOutput.write(" <groupid>" + group + "</groupid>\n");
- fwOutput.write(" <purpose></purpose>\n");
- fwOutput.write(" <version></version>\n");
- fwOutput.write(" <url>https://opends.dev.java.net</url>\n\n");
+ fwOutput.write(" <!-- A section describing each testgroup-->\n");
+ fwOutput.write(" <testgroup name=\"" + arrayData.getGroupName(0)
+ + "\">\n");
- fwOutput.write(" <!-- A section describing each testsuite-->\n");
- for(int i = 0; i < arrayData.sizeSuites(); i++)
- {
+ fwOutput.write(" <grouppurpose>" + arrayData.getGroupPurpose(0)
+ + "</grouppurpose>\n");
+ fwOutput.write(" <subgroupname>" + arrayData.getSubgroupName(0)
+ + "</subgroupname>\n");
+ fwOutput.write(" <category name=\"" + group + "\"/>\n");
+ fwOutput.write(" <groupid>" + group + "</groupid>\n");
+ fwOutput.write(" <purpose></purpose>\n");
+ fwOutput.write(" <version></version>\n");
+ fwOutput.write(" <url>https://opends.dev.java.net</url>\n\n");
+
+ fwOutput.write(" <!-- A section describing each testsuite-->\n");
+ for (int i = 0; i < arrayData.sizeSuites(); i++) {
String currTestSuite = new String(arrayData.getTestSuiteName(i));
String currTestGroup = arrayData.getTestGroup(i);
String currTestScript = arrayData.getTestScript(i);
String currTestHTMLLink = "";
- fwOutput.write(" <testsuite name=\"" + currTestSuite + "\">\n");
- fwOutput.write(" <purpose>" + arrayData.getTestSuitePurpose(i) + "</purpose>\n");
- fwOutput.write(" <suiteid>" + arrayData.getTestSuiteID(i) + "</suiteid>\n");
- fwOutput.write(" <group>" + arrayData.getTestSuiteGroup(i) + "</group>\n");
+ fwOutput.write(" <testsuite name=\"" + currTestSuite + "\">\n");
+ fwOutput.write(" <suitepurpose>" + arrayData.getTestSuitePurpose(i)
+ + "</suitepurpose>\n");
+ fwOutput.write(" <suiteid>" + arrayData.getTestSuiteID(i)
+ + "</suiteid>\n");
+ fwOutput.write(" <suitegroup>" + arrayData.getTestSuiteGroup(i)
+ + "</suitegroup>\n");
fwOutput.write(" <!-- A section describing each testcase-->\n");
- for(int j = 0; j < arrayData.size(); j++)
- {
- if(currTestSuite.indexOf(arrayData.getTestMarker(j)) == 0)
- {
- fwOutput.write(" <testcase name=\"" + arrayData.getTestName(j) + "\">\n");
- fwOutput.write(" <testid>" + arrayData.getTestID(j) + "</testid>\n");
- fwOutput.write(" <testissue>" + arrayData.getTestIssue(j) + "</testissue>\n");
+ for (int j = 0; j < arrayData.size(); j++) {
+ if (currTestSuite.indexOf(arrayData.getTestMarker(j)) == 0) {
+ fwOutput.write(" <testcase name=\""
+ + arrayData.getTestName(j) + "\">\n");
+ fwOutput.write(" <testid>" + arrayData.getTestID(j)
+ + "</testid>\n");
+ fwOutput.write(" <testissue>" + arrayData.getTestIssue(j)
+ + "</testissue>\n");
fwOutput.write(" <group>" + currTestGroup + "</group>\n");
- fwOutput.write(" <suite>" + currTestSuite.toString() + "</suite>\n");
- fwOutput.write(" <purpose>" + arrayData.getTestPurpose(j) + "</purpose>\n");
- fwOutput.write(" <testscript>" + currTestScript + "</testscript>\n");
+ fwOutput.write(" <suite>" + currTestSuite.toString()
+ + "</suite>\n");
+ fwOutput.write(" <purpose>" + arrayData.getTestPurpose(j)
+ + "</purpose>\n");
+ fwOutput.write(" <testscript>" + currTestScript
+ + "</testscript>\n");
fwOutput.write(" <steps>\n");
strIndividualSteps = arrayData.getTestSteps(j);
-
- for(int j2=0; j2<strIndividualSteps.size(); j2++)
- {
- fwOutput.write(" <step>\n");
- if(strIndividualSteps.size() > 1)
- fwOutput.write( Integer.toString(j2+1) + ". " + strIndividualSteps.get(j2) + "\n");
- else
- fwOutput.write( strIndividualSteps.get(j2) + "\n");
- fwOutput.write(" </step>\n");
+
+ for (int j2 = 0; j2 < strIndividualSteps.size(); j2++) {
+ fwOutput.write(" <step>\n");
+ if (strIndividualSteps.size() > 1)
+ fwOutput.write(Integer.toString(j2 + 1) + ". "
+ + strIndividualSteps.get(j2) + "\n");
+ else
+ fwOutput.write(strIndividualSteps.get(j2) + "\n");
+ fwOutput.write(" </step>\n");
}
fwOutput.write(" </steps>\n");
- String tmpString = new String(arrayData.getTestPreamble(j));
- if(tmpString.length() == 0)
- {
+ String tmpString = new String(arrayData.getTestPreamble(j));
+ if (tmpString.length() == 0) {
fwOutput.write(" <preamble>None</preamble>\n");
- }
- else
- {
- fwOutput.write(" <preamble>" + tmpString + "</preamble>\n");
- }
- tmpString = new String(arrayData.getTestPostamble(j));
- if(tmpString == null || tmpString.length() == 0)
- {
+ } else {
+ fwOutput.write(" <preamble>" + tmpString
+ + "</preamble>\n");
+ }
+ tmpString = new String(arrayData.getTestPostamble(j));
+ if (tmpString == null || tmpString.length() == 0) {
fwOutput.write(" <postamble>None</postamble>\n");
- }
- else
- {
- fwOutput.write(" <postamble>" + tmpString + "</postamble>\n");
- }
- fwOutput.write(" <postamble>" + arrayData.getTestPostamble(j) + "</postamble>\n");
+ } else {
+ fwOutput.write(" <postamble>" + tmpString
+ + "</postamble>\n");
+ }
+ fwOutput.write(" <postamble>"
+ + arrayData.getTestPostamble(j) + "</postamble>\n");
fwOutput.write(" <result>\n");
fwOutput.write(" " + arrayData.getTestResult(j) + "\n");
fwOutput.write(" </result>\n");
@@ -155,7 +160,8 @@
fwOutput.write(" </testsuite>\n\n");
}
- fwOutput.write(" </testgroup>\n");
+ fwOutput.write(" </testgroup>\n");
+ fwOutput.write(" </testphase>\n");
fwOutput.write(" </product>\n");
fwOutput.write("</qa>\n");
--
Gitblit v1.10.0