From 6acd01151edb98bc7d1009fd7b1acaf8909504ab 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

---
 opendj-sdk/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java             |  172 ++++++-----
 opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-index-stylesheet.xsl |  113 ++++++++
 opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-stylesheet.xsl       |  377 ++++++++++++++++++++++++++
 opendj-sdk/opends/tests/shared/java/parsingtool/WriteHTMLFile.java                |   98 +++++++
 opendj-sdk/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java      |   74 +++++
 5 files changed, 748 insertions(+), 86 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-index-stylesheet.xsl b/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-index-stylesheet.xsl
new file mode 100644
index 0000000..5f006a5
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-index-stylesheet.xsl
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html"/>
+
+<xsl:template match="/">
+
+  <xsl:element name="html">
+  
+    <xsl:variable name="opends-url" select="'https://opends.dev.java.net/'"/>
+    <xsl:variable name="opends-images" select="concat($opends-url,'public/images/')"/>
+    <xsl:variable name="opends-logo" select="concat($opends-images,'opends_logo_sm.png')"/>
+
+    <link rel="stylesheet" type="text/css" href="/branding/css/print.css" media="print"/>
+
+  <xsl:element name="head">
+
+    <link rel="stylesheet" type="text/css" href="/branding/css/print.css" media="print"/>
+    <link rel="stylesheet" href="https://opends.dev.java.net/public/css/opends.css" type="text/css"/>
+
+    <xsl:element name="title">
+      <xsl:value-of select="'Test Specification'"/>
+    </xsl:element>
+
+  </xsl:element>
+
+  <xsl:element name="body">
+
+    <xsl:element name="table">
+      <xsl:attribute name="class">
+        <xsl:value-of select="'tertmasttable'"/>
+      </xsl:attribute>
+      <xsl:attribute name="cellspacing">
+        <xsl:value-of select="'0'"/>
+      </xsl:attribute>
+      <xsl:attribute name="width">
+        <xsl:value-of select="'100%'"/>
+      </xsl:attribute>
+      <xsl:element name="tr">
+        <xsl:element name="td">
+          <xsl:element name="div">
+            <xsl:attribute name="class">
+              <xsl:value-of select="'collectionheader'"/>
+            </xsl:attribute>
+            <xsl:value-of select="'Test Specifications for OpenDS'"/>
+          </xsl:element>
+        </xsl:element>
+        <xsl:element name="td">
+          <xsl:attribute name="width">
+            <xsl:value-of select="'10%'"/>
+          </xsl:attribute>
+          <xsl:element name="a">
+            <xsl:attribute name="href">
+              <xsl:value-of select="$opends-url"/>
+            </xsl:attribute>
+              <xsl:element name="img">
+              <xsl:attribute name="src">
+                <xsl:value-of select="$opends-logo"/>
+              </xsl:attribute>
+              <xsl:attribute name="alt">
+                <xsl:value-of select="'OpenDS Logo'"/>
+              </xsl:attribute>
+              <xsl:attribute name="align">
+                <xsl:value-of select="'middle'"/>
+              </xsl:attribute>
+              <xsl:attribute name="border">
+                <xsl:value-of select="'0'"/>
+              </xsl:attribute>
+              <xsl:attribute name="height">
+                <xsl:value-of select="'33'"/>
+              </xsl:attribute>
+              <xsl:attribute name="width">
+                <xsl:value-of select="'104'"/>
+              </xsl:attribute>
+            </xsl:element>
+          </xsl:element>
+        </xsl:element>
+      </xsl:element>
+    </xsl:element>
+
+    <hr noshade="noshade" size="1" />
+
+    <xsl:element name="br"/>
+
+    <xsl:variable name="testspec" select="/qa/doc/testspec"/>
+
+    <xsl:element name="ol">
+
+    <xsl:for-each select="$testspec">
+
+      <!-- Test Spec List -->
+      <xsl:element name="li">
+        <xsl:element name="a">
+          <xsl:attribute name="href">
+            <xsl:value-of select="@location"/>
+          </xsl:attribute>
+          <xsl:value-of select="@name"/>
+        </xsl:element>
+      </xsl:element>
+
+    </xsl:for-each>
+
+    </xsl:element>
+
+    </xsl:element> 
+     
+  </xsl:element>
+
+
+</xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-stylesheet.xsl b/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-stylesheet.xsl
new file mode 100644
index 0000000..bc04f70
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/xsl/testspec-stylesheet.xsl
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html"/>
+
+<xsl:template match="/">
+
+  <xsl:element name="html">
+  
+    <xsl:variable name="opends-url" select="'https://opends.dev.java.net/'"/>
+    <xsl:variable name="opends-images" select="concat($opends-url,'public/images/')"/>
+    <xsl:variable name="opends-logo" select="concat($opends-images,'opends_logo_sm.png')"/>
+
+    <link rel="stylesheet" type="text/css" href="/branding/css/print.css" media="print"/>
+
+  <xsl:element name="head">
+
+    <link rel="stylesheet" type="text/css" href="/branding/css/print.css" media="print"/>
+    <link rel="stylesheet" href="https://opends.dev.java.net/public/css/opends.css" type="text/css"/>
+
+    <xsl:element name="title">
+      <xsl:value-of select="'Test Specification'"/>
+    </xsl:element>
+
+  </xsl:element>
+
+  <xsl:element name="body">
+
+    <xsl:variable name="testgroup" select="/qa/product/testphase/testgroup"/>
+                   
+    <xsl:for-each select="$testgroup">
+        
+        <xsl:element name="table">
+          <xsl:attribute name="class">
+            <xsl:value-of select="'tertmasttable'"/>
+          </xsl:attribute>
+          <xsl:attribute name="cellspacing">
+            <xsl:value-of select="'0'"/>
+          </xsl:attribute>
+          <xsl:attribute name="width">
+            <xsl:value-of select="'100%'"/>
+          </xsl:attribute>
+          <xsl:element name="tr">
+            <xsl:element name="td">
+              <xsl:element name="div">
+                <xsl:attribute name="class">
+                  <xsl:value-of select="'collectionheader'"/>
+                </xsl:attribute>
+                <xsl:value-of select="concat('Test Specification for ',@name)"/>
+              </xsl:element>
+            </xsl:element>
+            <xsl:element name="td">
+              <xsl:attribute name="width">
+                <xsl:value-of select="'10%'"/>
+              </xsl:attribute>
+              <xsl:element name="a">
+                <xsl:attribute name="href">
+                  <xsl:value-of select="$opends-url"/>
+                </xsl:attribute>
+                  <xsl:element name="img">
+                  <xsl:attribute name="src">
+                    <xsl:value-of select="$opends-logo"/>
+                  </xsl:attribute>
+                  <xsl:attribute name="alt">
+                    <xsl:value-of select="'OpenDS Logo'"/>
+                  </xsl:attribute>
+                  <xsl:attribute name="align">
+                    <xsl:value-of select="'middle'"/>
+                  </xsl:attribute>
+                  <xsl:attribute name="border">
+                    <xsl:value-of select="'0'"/>
+                  </xsl:attribute>
+                  <xsl:attribute name="height">
+                    <xsl:value-of select="'33'"/>
+                  </xsl:attribute>
+                  <xsl:attribute name="width">
+                    <xsl:value-of select="'104'"/>
+                  </xsl:attribute>
+                </xsl:element>
+              </xsl:element>
+            </xsl:element>
+          </xsl:element>
+        </xsl:element>
+
+        <hr noshade="noshade" size="1" />
+
+        <xsl:element name="br"/>
+
+        <!-- Test Group Table -->
+        <xsl:element name="table">
+        
+          <xsl:attribute name="border">1</xsl:attribute>
+          <xsl:attribute name="width">80%</xsl:attribute>
+
+          <xsl:element name="tr">
+            <xsl:attribute name="bgcolor">yellow</xsl:attribute>
+            <xsl:element name="td">
+              <xsl:attribute name="width">20%</xsl:attribute>
+              <xsl:element name="b">
+                <xsl:value-of select="'Test Group'"/>
+              </xsl:element>
+            </xsl:element>
+            <xsl:element name="td">
+                <xsl:value-of select="@name"/>
+            </xsl:element>
+          </xsl:element>
+
+          <xsl:element name="tr">
+            <xsl:element name="td">
+              <xsl:attribute name="width">20%</xsl:attribute>
+              <xsl:element name="b">
+                <xsl:value-of select="'Test Group Purpose'"/>
+              </xsl:element>
+            </xsl:element>
+            <xsl:element name="td">
+                <xsl:value-of select="grouppurpose"/>
+            </xsl:element>
+          </xsl:element>
+
+        </xsl:element>
+
+        <xsl:element name="br"/>
+        
+        <!-- Test Suite List -->
+        <xsl:element name="ol">
+          <xsl:for-each select="testsuite">
+            <xsl:element name="li">
+              <xsl:element name="a">
+                <xsl:attribute name="href">
+                  <xsl:value-of select="concat('#',@name)"/>
+                </xsl:attribute>
+                <xsl:value-of select="@name"/>
+              </xsl:element>
+              <xsl:value-of select="concat(' : ',suitepurpose)"/>
+            </xsl:element>
+          </xsl:for-each>
+        </xsl:element>
+
+        <xsl:for-each select="testsuite">
+        
+          <!-- Test Suite Header -->
+          <xsl:element name="h2">
+            <xsl:value-of select="@name"/>
+          </xsl:element>
+
+          <!-- Test Suite Anchor -->
+          <xsl:element name="a">
+            <xsl:attribute name="name">
+              <xsl:value-of select="@name"/>
+            </xsl:attribute>
+          </xsl:element>
+                             
+          <!-- Test Suite Table -->
+          <xsl:element name="table">
+          
+            <xsl:attribute name="border">1</xsl:attribute>
+            <xsl:attribute name="width">80%</xsl:attribute>
+            
+            <xsl:element name="tr">
+              <xsl:attribute name="bgcolor">aqua</xsl:attribute>
+              <xsl:element name="td">
+                <xsl:attribute name="width">20%</xsl:attribute>
+                <xsl:element name="b"> 
+                  <xsl:value-of select="'Test Suite Name'"/>
+                </xsl:element>
+              </xsl:element>
+              <xsl:element name="td">
+                  <xsl:value-of select="@name"/>
+              </xsl:element>
+            </xsl:element>
+
+            <xsl:element name="tr">
+              <xsl:element name="td">
+                <xsl:attribute name="width">20%</xsl:attribute>
+                <xsl:element name="b">
+                  <xsl:value-of select="'Purpose'"/>
+                </xsl:element>
+              </xsl:element>
+              <xsl:element name="td">
+                  <xsl:value-of select="suitepurpose"/>
+              </xsl:element>
+            </xsl:element>
+
+            <xsl:element name="tr">
+              <xsl:element name="td">
+                <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Suite Group'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="suitegroup"/>
+              </xsl:element>
+            </xsl:element>
+                                
+            </xsl:element>          
+
+            <xsl:element name="br"/>
+
+            <!-- Test Case List -->
+            <xsl:element name="ol">
+              <xsl:for-each select="testcase">
+                <xsl:element name="li">
+                  <xsl:element name="a">
+                    <xsl:attribute name="href">
+                      <xsl:value-of select="concat('#',../@name,@name)"/>
+                    </xsl:attribute>
+                    <xsl:value-of select="@name"/>
+                  </xsl:element>
+                  <xsl:value-of select="concat(' : ',purpose)"/>
+                </xsl:element>
+              </xsl:for-each>
+            </xsl:element>
+
+            <xsl:element name="br"/>
+        
+            <!-- Test Cases -->
+            <xsl:for-each select="testcase">
+        
+              <!-- Test Case Table -->       
+              <xsl:element name="table">
+                <xsl:attribute name="border">1</xsl:attribute>
+                <xsl:attribute name="width">80%</xsl:attribute>
+           
+              <!-- Test Case Anchor -->
+              <xsl:element name="a">
+                <xsl:attribute name="name">
+                  <xsl:value-of select="concat(../@name,@name)"/>
+                </xsl:attribute>
+              </xsl:element>
+
+              <!-- Test Name -->
+              <xsl:element name="a">
+                <xsl:attribute name="name">
+                  <xsl:value-of select="testid"/>
+                </xsl:attribute>
+              </xsl:element>
+              <xsl:element name="tr">
+                <xsl:attribute name="bgcolor">lightblue</xsl:attribute>              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="a">
+                    <xsl:attribute name="width">20%</xsl:attribute>
+                  </xsl:element>
+                  <xsl:element name="b">
+                    <xsl:value-of select="'Test Name'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="@name"/>
+                </xsl:element>
+              </xsl:element>
+
+              <!-- Test Purpose -->          
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Test Purpose'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="purpose"/>
+                </xsl:element>
+              </xsl:element>
+                                             
+              <!-- Test Script -->            
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Test Script'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:element name="a">
+                    <xsl:attribute name="href">
+                      <xsl:value-of select="testscript"/>
+                    </xsl:attribute>
+                    <xsl:value-of select="testscript"/>
+                  </xsl:element>
+                </xsl:element>
+              </xsl:element>
+                                               
+              <!-- Test Issue -->            
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Test Issue'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:element name="a">
+                    <xsl:attribute name="href">
+                      <xsl:value-of select="concat('https://opends.dev.java.net/issues/show_bug.cgi?id=',testissue)"/>
+                    </xsl:attribute>
+                    <xsl:value-of select="testissue"/>
+                  </xsl:element>
+                </xsl:element>
+              </xsl:element>
+                                               
+              <!-- Test Preamble -->          
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Preamble'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="preamble"/>
+                </xsl:element>
+              </xsl:element>
+                                                                                     
+              <!-- Test Steps -->          
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Test Steps'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:for-each select="steps/step">
+                    <xsl:value-of select="."/>
+                    <xsl:element name="br"/>    
+                  </xsl:for-each>
+                </xsl:element>
+              </xsl:element>
+                                            
+              <!-- Test Postamble -->          
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Postamble'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="postamble"/>
+                </xsl:element>
+              </xsl:element>
+                                                                                                   
+              <!-- Test Result -->          
+              <xsl:element name="tr">              
+                <xsl:element name="td">
+                  <xsl:attribute name="width">20%</xsl:attribute>
+                  <xsl:element name="b"> 
+                    <xsl:value-of select="'Test Result'"/>
+                  </xsl:element>
+                </xsl:element>
+                <xsl:element name="td">
+                  <xsl:value-of select="result"/>
+                </xsl:element>
+              </xsl:element>
+                                                                                                                    
+            </xsl:element>
+        
+            <xsl:element name="br"/>    
+    
+          </xsl:for-each>
+                  
+        </xsl:for-each>
+
+    </xsl:for-each>
+
+
+    </xsl:element> 
+     
+  </xsl:element>
+
+
+</xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/opendj-sdk/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java b/opendj-sdk/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java
index 1898aaa..234a978 100644
--- a/opendj-sdk/opends/tests/shared/java/parsingtool/GenerateOpenDSTestSpecs.java
+++ b/opendj-sdk/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;
       
   }
-
+  
 }
diff --git a/opendj-sdk/opends/tests/shared/java/parsingtool/WriteHTMLFile.java b/opendj-sdk/opends/tests/shared/java/parsingtool/WriteHTMLFile.java
new file mode 100644
index 0000000..2fd1475
--- /dev/null
+++ b/opendj-sdk/opends/tests/shared/java/parsingtool/WriteHTMLFile.java
@@ -0,0 +1,98 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+import java.io.*;
+import java.lang.*;
+import java.util.ArrayList;
+import javax.xml.transform.*;
+import java.net.*;
+
+public class WriteHTMLFile
+{
+  private String group;
+  private ArrayData arrayData;
+  private ArrayList <String> strIndividualSteps;
+
+  public WriteHTMLFile(String inGroup)
+  {
+    group = inGroup;
+    strIndividualSteps = null;
+  }
+    
+  public void MakeHTMLFile(ArrayData arrayData, String strDir, String strParentDir) 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);
+      } 
+    }
+
+    String xmlFilename;
+    String htmlFilename;
+    File xslFilename = new File(strParentDir + "/../shared/xsl/testspec-stylesheet.xsl");
+
+    if(group.indexOf("/") < 0)
+    {
+        xmlFilename = strDirName + "/" + group + ".xml";
+        htmlFilename = strDirName + "/" + group + ".html";
+    }
+    else
+    {
+        String tmpStr = new String(group);
+        int index = tmpStr.indexOf("/") + 1;
+        String subStr = tmpStr.substring(index);
+        xmlFilename = strDirName + "/" + subStr + ".xml";
+        htmlFilename = strDirName + "/" + subStr + ".html";
+    }
+      
+    System.out.println("Processing: " + xmlFilename);
+    
+    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( );
+      }
+    
+  }
+
+}
diff --git a/opendj-sdk/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java b/opendj-sdk/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java
index db1b06b..21ff98b 100644
--- a/opendj-sdk/opends/tests/shared/java/parsingtool/WriteXMLFile_xml.java
+++ b/opendj-sdk/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