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/GenerateOpenDSTestSpecs.java | 74 +++++++++++++++++++++++++++++++++++-
1 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java b/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java
index 1898aaa..234a978 100644
--- a/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java
+++ b/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java
@@ -27,6 +27,7 @@
import java.io.*;
import java.lang.*;
import java.util.ArrayList;
+import javax.xml.transform.*;
public class GenerateOpenDSTestSpecs
{
@@ -40,7 +41,7 @@
public GenerateOpenDSTestSpecs()
{
}
-
+
public static void main(String[] args)
{
// retrieve input
@@ -58,6 +59,7 @@
// validate input
File fileDirName = new File(strParentDirName);
+
if(!fileDirName.isDirectory())
{
fatalMsg(fileDirName + " is not a directory.");
@@ -179,18 +181,84 @@
else if(strFileFormat.startsWith("xml"))
{
WriteXMLFile_xml xmlFile = new WriteXMLFile_xml(arrayData.getTestSuite(0));
+ WriteHTMLFile htmlFile = new WriteHTMLFile(arrayData.getTestSuite(0));
try
{
xmlFile.MakeXMLFile(arrayData, strOutputDirName);
+ htmlFile.MakeHTMLFile(arrayData, strOutputDirName,strParentDirName);
}
catch(Exception e)
{
e.printStackTrace();
}
}
+
}
+
}
+
+ // Write the index file
+ if(strFileFormat.startsWith("xml"))
+ {
+
+ // Index.xml
+ try {
+ File indexFile = new File(strOutputDirName + "/index.xml");
+ FileWriter indexFileout = new FileWriter(indexFile);
+
+ indexFileout.write("<?xml version=\"1.0\"?>\n\n");
+ indexFileout.write("<qa>\n");
+ indexFileout.write(" <doc>\n");
+ for(int k = 0; k < arrayTests.size(); k++)
+ {
+
+ ArrayData testSuitePath = (ArrayData)(arrayTests.get(k));
+ if(testSuitePath.size() > 0)
+ {
+
+ String specPath=testSuitePath.getTestSuite(0);
+
+ String specName = (new File(specPath)).getName();
+
+ String specFile=strOutputDirName + "/" + specPath + "/" + specName + ".html";
+
+ indexFileout.write(" <testspec name=\"" + specName + "\" location=\"" + specFile + "\"/>\n");
+ }
+ }
+
+ indexFileout.write(" </doc>\n");
+ indexFileout.write("</qa>\n");
+ indexFileout.close();
+
+ }
+ catch (Exception e) {
+ e.printStackTrace( );
+ }
+
+ // Index.html
+ File xmlFilename= new File(strOutputDirName + "/index.xml");
+ File xslFilename = new File(strParentDirName + "/../shared/xsl/testspec-index-stylesheet.xsl");
+ File htmlFilename = new File(strOutputDirName + "/index.html");
+ try{
+ TransformerFactory transFactory = TransformerFactory.newInstance();
+
+ Transformer transformer = transFactory.newTransformer
+ (new javax.xml.transform.stream.StreamSource(xslFilename));
+
+ transformer.transform
+ (new javax.xml.transform.stream.StreamSource(xmlFilename),
+ new javax.xml.transform.stream.StreamResult
+ (new FileOutputStream(htmlFilename))
+ );
+ }
+
+ catch (Exception e) {
+ e.printStackTrace( );
+ }
+
+ }
+
System.out.println("Files successfully written to the output directory.");
}
@@ -211,7 +279,7 @@
System.out.println(str);
System.out.println("exiting.....");
}
-
+
private static String parseSuite(File inDir, String strParentDir)
{
String tmpStr = new String(inDir.toString());
@@ -221,5 +289,5 @@
return subStr;
}
-
+
}
--
Gitblit v1.10.0