mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Christophe Sovant
04.28.2007 6301c54f54dac5b7eccbe8786e1b98a5e9a3e5e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * 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;
 
public class WriteXMLFile_int
{
  private String group;
  private ArrayData arrayData;
 
  public WriteXMLFile_int(String inGroup)
  {
    group = inGroup;
  }
 
  public void MakeXMLFile(ArrayData arrayData, String strDir) throws IOException
  {
    //System.out.println("For " + group + " the number of suites is " + Integer.toString(arrayData.sizeSuites()));
    //System.out.println("The number of tests is " + Integer.toString(arrayData.size()));
 
    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 strFilename = strDirName + "/" + group + ".xml";
    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("  <!-- 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=\"Integration\">\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>http://samsonite.central.sun.com/" + group + "</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));
      //System.out.println("currTestSuite is " + currTestSuite.toString());
      String currTestGroup = arrayData.getTestGroup(i);
      String currTestScript = arrayData.getTestScript(i);
      String currTestHTMLLink = "";
      //String currTestHTMLLink = arrayData.getTestHTMLLink(i);
      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\n");
 
      fwOutput.write("         <!-- A section describing each testcase-->\n");
      //System.out.println("arrayData size is " + Integer.toString(arrayData.size()));
      for(int j = 0; j < arrayData.size(); j++)
      {
    //System.out.println("Test Marker is\n" + arrayData.getTestMarker(j));
    //System.out.println("currTestSuite is\n" + currTestSuite);
        //System.out.println(" ");
    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>\n");
          fwOutput.write("                        <a href=\"" + currTestHTMLLink +  "\">" + currTestScript + "</a>\n");
          fwOutput.write("            </testscript>\n");
          fwOutput.write("            <steps>\n");
          fwOutput.write("              <step>\n");
          fwOutput.write("               " + arrayData.getTestSteps(j) + "\n");
          fwOutput.write("              </step>\n");
          fwOutput.write("            </steps>\n");
      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.length() == 0)
      {
            fwOutput.write("            <postamble>None</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");
          fwOutput.write("         </testcase>\n\n");
        }
      }
      fwOutput.write("      </testsuite>\n\n");
    }
 
    fwOutput.write("    </testgroup>\n");
    fwOutput.write("  </product>\n");
    fwOutput.write("</qa>\n");
 
    fwOutput.close();
 
  }
 
}