10139N/A/*
10139N/A * CDDL HEADER START
10139N/A *
17365N/A * The contents of this file are subject to the terms of the
10139N/A * Common Development and Distribution License, Version 1.0 only
10139N/A * (the "License"). You may not use this file except in compliance
10139N/A * with the License.
17185N/A *
10139N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
17178N/A * or http://forgerock.org/license/CDDLv1.0.html.
18603N/A * See the License for the specific language governing permissions
17178N/A * and limitations under the License.
10139N/A *
15322N/A * When distributing Covered Code, include this CDDL HEADER in each
10139N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
18532N/A * If applicable, add the following below this CDDL HEADER, with the
10139N/A * fields enclosed by brackets "[]" replaced with your own identifying
10139N/A * information:
18616N/A * Portions Copyright [yyyy] [name of copyright owner]
10139N/A *
16215N/A * CDDL HEADER END
12773N/A *
12773N/A *
12773N/A * Copyright 2008 Sun Microsystems, Inc.
12204N/A */
12725N/Aimport java.io.*;
17606N/Aimport java.lang.*;
17766N/Aimport java.util.ArrayList;
18063N/A
18063N/Apublic class WriteXMLFile_int
18666N/A{
18666N/A private String group;
10139N/A private ArrayData arrayData;
10139N/A
10139N/A public WriteXMLFile_int(String inGroup)
10139N/A {
10139N/A group = inGroup;
10139N/A }
10139N/A
10139N/A public void MakeXMLFile(ArrayData arrayData, String strDir) throws IOException
10139N/A {
10139N/A //System.out.println("For " + group + " the number of suites is " + Integer.toString(arrayData.sizeSuites()));
10139N/A //System.out.println("The number of tests is " + Integer.toString(arrayData.size()));
10139N/A
10139N/A String strDirName = strDir + "/" + group;
10139N/A File fileDirName = new File(strDirName);
10139N/A if(!fileDirName.isDirectory())
10139N/A {
10139N/A if(!fileDirName.mkdirs())
10139N/A {
10139N/A System.out.println("Could not create directory, " + strDirName);
10139N/A System.out.println("Exiting.....");
10139N/A System.exit(0);
10139N/A }
10139N/A }
10139N/A
10139N/A String strFilename = strDirName + "/" + group + ".xml";
10139N/A File fileOutput = new File(strFilename);
17473N/A FileWriter fwOutput = new FileWriter(fileOutput);
18063N/A
18666N/A fwOutput.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
10139N/A fwOutput.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + group + ".xsl\"?>\n");
10139N/A fwOutput.write("<qa xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"no-schema-yet.xsd\">\n\n");
10139N/A
10139N/A fwOutput.write(" <!-- A section describing each product under test -->\n");
10139N/A fwOutput.write(" <product name=\"OpenDS\">\n\n");
10139N/A
10139N/A fwOutput.write(" <!-- A section describing each testgroup-->\n");
10139N/A fwOutput.write(" <testgroup name=\"Integration\">\n");
10139N/A fwOutput.write(" <category name=\"" + group + "\"/>\n");
10139N/A fwOutput.write(" <groupid>" + group + "</groupid>\n");
10139N/A fwOutput.write(" <purpose></purpose>\n");
10139N/A fwOutput.write(" <version></version>\n");
10139N/A fwOutput.write(" <url>http://samsonite.central.sun.com/" + group + "</url>\n\n");
17460N/A
16129N/A fwOutput.write(" <!-- A section describing each testsuite-->\n");
10139N/A for(int i = 0; i < arrayData.sizeSuites(); i++)
10139N/A {
10139N/A String currTestSuite = new String(arrayData.getTestSuiteName(i));
10139N/A //System.out.println("currTestSuite is " + currTestSuite.toString());
10139N/A String currTestGroup = arrayData.getTestGroup(i);
10139N/A String currTestScript = arrayData.getTestScript(i);
10139N/A String currTestHTMLLink = "";
10139N/A //String currTestHTMLLink = arrayData.getTestHTMLLink(i);
11303N/A fwOutput.write(" <testsuite name=\"" + currTestSuite + "\">\n");
12773N/A fwOutput.write(" <purpose>" + arrayData.getTestSuitePurpose(i) + "</purpose>\n");
12773N/A fwOutput.write(" <suiteid>" + arrayData.getTestSuiteID(i) + "</suiteid>\n");
12773N/A fwOutput.write(" <group>" + arrayData.getTestSuiteGroup(i) + "</group>\n\n");
12773N/A
12773N/A fwOutput.write(" <!-- A section describing each testcase-->\n");
10139N/A //System.out.println("arrayData size is " + Integer.toString(arrayData.size()));
10139N/A for(int j = 0; j < arrayData.size(); j++)
10139N/A {
10139N/A //System.out.println("Test Marker is\n" + arrayData.getTestMarker(j));
10139N/A //System.out.println("currTestSuite is\n" + currTestSuite);
10139N/A //System.out.println(" ");
10139N/A if(currTestSuite.indexOf(arrayData.getTestMarker(j)) >= 0)
12173N/A {
12173N/A fwOutput.write(" <testcase name=\"" + arrayData.getTestName(j) + "\">\n");
10139N/A fwOutput.write(" <testid>" + arrayData.getTestID(j) + "</testid>\n");
10139N/A //fwOutput.write(" <testissue>" + arrayData.getTestIssue(j) + "</testissue>\n");
10139N/A fwOutput.write(" <group>" + currTestGroup + "</group>\n");
10139N/A fwOutput.write(" <suite>" + currTestSuite.toString() + "</suite>\n");
10139N/A fwOutput.write(" <purpose>" + arrayData.getTestPurpose(j) + "</purpose>\n");
10139N/A fwOutput.write(" <testscript>\n");
10139N/A fwOutput.write(" <a href=\"" + currTestHTMLLink + "\">" + currTestScript + "</a>\n");
10139N/A fwOutput.write(" </testscript>\n");
10139N/A fwOutput.write(" <steps>\n");
13963N/A fwOutput.write(" <step>\n");
10139N/A fwOutput.write(" " + arrayData.getTestSteps(j) + "\n");
10139N/A fwOutput.write(" </step>\n");
10139N/A fwOutput.write(" </steps>\n");
10139N/A String tmpString = new String(arrayData.getTestPreamble(j));
10139N/A if(tmpString.length() == 0)
10139N/A {
10139N/A fwOutput.write(" <preamble>None</preamble>\n");
10139N/A }
10139N/A else
10273N/A {
10139N/A fwOutput.write(" <preamble>" + tmpString + "</preamble>\n");
10139N/A }
10139N/A tmpString = new String(arrayData.getTestPostamble(j));
10139N/A if(tmpString.length() == 0)
10139N/A {
10139N/A fwOutput.write(" <postamble>None</postamble>\n");
10139N/A }
10139N/A else
10139N/A {
10139N/A fwOutput.write(" <postamble>" + tmpString + "</postamble>\n");
10139N/A }
10139N/A fwOutput.write(" <postamble>" + arrayData.getTestPostamble(j) + "</postamble>\n");
10139N/A fwOutput.write(" <result>\n");
10139N/A fwOutput.write(" " + arrayData.getTestResult(j) + "\n");
10139N/A fwOutput.write(" </result>\n");
10139N/A fwOutput.write(" </testcase>\n\n");
10139N/A }
10139N/A }
10139N/A fwOutput.write(" </testsuite>\n\n");
10139N/A }
10139N/A
10139N/A fwOutput.write(" </testgroup>\n");
10139N/A fwOutput.write(" </product>\n");
18666N/A fwOutput.write("</qa>\n");
18666N/A
18666N/A fwOutput.close();
18524N/A
18524N/A }
18524N/A
18430N/A}
18430N/A