2788N/A/*
2788N/A * CDDL HEADER START
2788N/A *
2788N/A * The contents of this file are subject to the terms of the
2788N/A * Common Development and Distribution License, Version 1.0 only
2788N/A * (the "License"). You may not use this file except in compliance
2788N/A * with the License.
2788N/A *
2788N/A * You can obtain a copy of the license at
2788N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
2788N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
2788N/A * See the License for the specific language governing permissions
2788N/A * and limitations under the License.
2788N/A *
2788N/A * When distributing Covered Code, include this CDDL HEADER in each
2788N/A * file and include the License file at
2788N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
2788N/A * add the following below this CDDL HEADER, with the fields enclosed
2788N/A * by brackets "[]" replaced with your own identifying information:
2788N/A * Portions Copyright [yyyy] [name of copyright owner]
2788N/A *
2788N/A * CDDL HEADER END
2788N/A *
2788N/A *
3215N/A * Copyright 2008 Sun Microsystems, Inc.
2788N/A */
2788N/Aimport java.io.*;
2788N/Aimport java.lang.*;
2788N/Aimport java.util.ArrayList;
2788N/A
2907N/Apublic class WriteXMLFile_xml {
2788N/A private String group;
2907N/A
2788N/A private ArrayData arrayData;
2788N/A
2907N/A private ArrayList<String> strIndividualSteps;
2907N/A
2907N/A public WriteXMLFile_xml(String inGroup) {
2788N/A group = inGroup;
2788N/A strIndividualSteps = null;
2788N/A }
2788N/A
2907N/A public void MakeXMLFile(ArrayData arrayData, String strDir)
2907N/A throws IOException {
2788N/A String strDirName = strDir + "/" + group;
2788N/A File fileDirName = new File(strDirName);
2907N/A if (!fileDirName.isDirectory()) {
2907N/A if (!fileDirName.mkdirs()) {
2907N/A System.out.println("Could not create directory, " + strDirName);
2907N/A System.out.println("Exiting.....");
2907N/A System.exit(0);
2907N/A }
2788N/A }
2788N/A
2788N/A String strFilename;
2907N/A if (group.indexOf("/") < 0) {
2907N/A strFilename = strDirName + "/" + group + ".xml";
2907N/A } else {
2907N/A String tmpStr = new String(group);
2907N/A int index = tmpStr.indexOf("/") + 1;
2907N/A String subStr = tmpStr.substring(index);
2907N/A strFilename = strDirName + "/" + subStr + ".xml";
2788N/A }
2907N/A
2907N/A //System.out.println("Processing: " + strFilename);
2788N/A
2788N/A File fileOutput = new File(strFilename);
2788N/A FileWriter fwOutput = new FileWriter(fileOutput);
2788N/A
2907N/A fwOutput.write("<?xml version=\"1.0\"?>\n\n");
2907N/A
2907N/A fwOutput.write("<qa>\n");
2788N/A
2788N/A fwOutput.write(" <!-- A section describing each product under test -->\n");
2788N/A fwOutput.write(" <product name=\"OpenDS\">\n\n");
2788N/A
2907N/A fwOutput.write(" <!-- A section describing each testphase-->\n");
2907N/A fwOutput.write(" <testphase name=\"Functional\">\n\n");
2907N/A
2907N/A fwOutput.write(" <!-- A section describing each testgroup-->\n");
2907N/A fwOutput.write(" <testgroup name=\"" + arrayData.getGroupName(0)
2907N/A + "\">\n");
2788N/A
2907N/A fwOutput.write(" <grouppurpose>" + arrayData.getGroupPurpose(0)
2907N/A + "</grouppurpose>\n");
2907N/A fwOutput.write(" <subgroupname>" + arrayData.getSubgroupName(0)
2907N/A + "</subgroupname>\n");
2907N/A fwOutput.write(" <category name=\"" + group + "\"/>\n");
2907N/A fwOutput.write(" <groupid>" + group + "</groupid>\n");
2907N/A fwOutput.write(" <purpose></purpose>\n");
2907N/A fwOutput.write(" <version></version>\n");
2907N/A fwOutput.write(" <url>https://opends.dev.java.net</url>\n\n");
2788N/A
2907N/A fwOutput.write(" <!-- A section describing each testsuite-->\n");
2907N/A for (int i = 0; i < arrayData.sizeSuites(); i++) {
2788N/A String currTestSuite = new String(arrayData.getTestSuiteName(i));
2788N/A String currTestGroup = arrayData.getTestGroup(i);
2788N/A String currTestScript = arrayData.getTestScript(i);
2788N/A String currTestHTMLLink = "";
2907N/A fwOutput.write(" <testsuite name=\"" + currTestSuite + "\">\n");
2907N/A fwOutput.write(" <suitepurpose>" + arrayData.getTestSuitePurpose(i)
2907N/A + "</suitepurpose>\n");
2907N/A fwOutput.write(" <suiteid>" + arrayData.getTestSuiteID(i)
2907N/A + "</suiteid>\n");
2907N/A fwOutput.write(" <suitegroup>" + arrayData.getTestSuiteGroup(i)
2907N/A + "</suitegroup>\n");
2788N/A
2788N/A fwOutput.write(" <!-- A section describing each testcase-->\n");
2788N/A
2907N/A for (int j = 0; j < arrayData.size(); j++) {
2907N/A if (currTestSuite.indexOf(arrayData.getTestMarker(j)) == 0) {
2907N/A fwOutput.write(" <testcase name=\""
2907N/A + arrayData.getTestName(j) + "\">\n");
2907N/A fwOutput.write(" <testid>" + arrayData.getTestID(j)
2907N/A + "</testid>\n");
2907N/A fwOutput.write(" <testissue>" + arrayData.getTestIssue(j)
2907N/A + "</testissue>\n");
2788N/A fwOutput.write(" <group>" + currTestGroup + "</group>\n");
2907N/A fwOutput.write(" <suite>" + currTestSuite.toString()
2907N/A + "</suite>\n");
2907N/A fwOutput.write(" <purpose>" + arrayData.getTestPurpose(j)
2907N/A + "</purpose>\n");
2907N/A fwOutput.write(" <testscript>" + currTestScript
2907N/A + "</testscript>\n");
2788N/A fwOutput.write(" <steps>\n");
2788N/A strIndividualSteps = arrayData.getTestSteps(j);
2907N/A
2907N/A for (int j2 = 0; j2 < strIndividualSteps.size(); j2++) {
2907N/A fwOutput.write(" <step>\n");
2907N/A if (strIndividualSteps.size() > 1)
2907N/A fwOutput.write(Integer.toString(j2 + 1) + ". "
2907N/A + strIndividualSteps.get(j2) + "\n");
2907N/A else
2907N/A fwOutput.write(strIndividualSteps.get(j2) + "\n");
2907N/A fwOutput.write(" </step>\n");
2788N/A }
2788N/A fwOutput.write(" </steps>\n");
3431N/A String tmpString = arrayData.getTestPreamble(j);
3431N/A if (tmpString == null || tmpString.length() == 0) {
2788N/A fwOutput.write(" <preamble>None</preamble>\n");
2907N/A } else {
2907N/A fwOutput.write(" <preamble>" + tmpString
2907N/A + "</preamble>\n");
2907N/A }
3431N/A tmpString = arrayData.getTestPostamble(j);
2907N/A if (tmpString == null || tmpString.length() == 0) {
2788N/A fwOutput.write(" <postamble>None</postamble>\n");
2907N/A } else {
2907N/A fwOutput.write(" <postamble>" + tmpString
2907N/A + "</postamble>\n");
2907N/A }
2788N/A fwOutput.write(" <result>\n");
2788N/A fwOutput.write(" " + arrayData.getTestResult(j) + "\n");
2788N/A fwOutput.write(" </result>\n");
2788N/A fwOutput.write(" </testcase>\n\n");
2788N/A }
2788N/A }
2788N/A fwOutput.write(" </testsuite>\n\n");
2788N/A }
2788N/A
2907N/A fwOutput.write(" </testgroup>\n");
2907N/A fwOutput.write(" </testphase>\n");
2788N/A fwOutput.write(" </product>\n");
2788N/A fwOutput.write("</qa>\n");
2788N/A
2788N/A fwOutput.close();
2788N/A
2788N/A }
2788N/A
2788N/A}