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
2788N/Apublic class WriteXMLFile_int
2788N/A{
2788N/A private String group;
2788N/A private ArrayData arrayData;
2788N/A
2788N/A public WriteXMLFile_int(String inGroup)
2788N/A {
2788N/A group = inGroup;
2788N/A }
2788N/A
2788N/A public void MakeXMLFile(ArrayData arrayData, String strDir) throws IOException
2788N/A {
2788N/A //System.out.println("For " + group + " the number of suites is " + Integer.toString(arrayData.sizeSuites()));
2788N/A //System.out.println("The number of tests is " + Integer.toString(arrayData.size()));
2788N/A
2788N/A String strDirName = strDir + "/" + group;
2788N/A File fileDirName = new File(strDirName);
2788N/A if(!fileDirName.isDirectory())
2788N/A {
2788N/A if(!fileDirName.mkdirs())
2788N/A {
2788N/A System.out.println("Could not create directory, " + strDirName);
2788N/A System.out.println("Exiting.....");
2788N/A System.exit(0);
2788N/A }
2788N/A }
2788N/A
2788N/A String strFilename = strDirName + "/" + group + ".xml";
2788N/A File fileOutput = new File(strFilename);
2788N/A FileWriter fwOutput = new FileWriter(fileOutput);
2788N/A
2788N/A fwOutput.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
2788N/A fwOutput.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + group + ".xsl\"?>\n");
2788N/A fwOutput.write("<qa xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"no-schema-yet.xsd\">\n\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
2788N/A fwOutput.write(" <!-- A section describing each testgroup-->\n");
2788N/A fwOutput.write(" <testgroup name=\"Integration\">\n");
2788N/A fwOutput.write(" <category name=\"" + group + "\"/>\n");
2788N/A fwOutput.write(" <groupid>" + group + "</groupid>\n");
2788N/A fwOutput.write(" <purpose></purpose>\n");
2788N/A fwOutput.write(" <version></version>\n");
2788N/A fwOutput.write(" <url>http://samsonite.central.sun.com/" + group + "</url>\n\n");
2788N/A
2788N/A fwOutput.write(" <!-- A section describing each testsuite-->\n");
2788N/A for(int i = 0; i < arrayData.sizeSuites(); i++)
2788N/A {
2788N/A String currTestSuite = new String(arrayData.getTestSuiteName(i));
2788N/A //System.out.println("currTestSuite is " + currTestSuite.toString());
2788N/A String currTestGroup = arrayData.getTestGroup(i);
2788N/A String currTestScript = arrayData.getTestScript(i);
2788N/A String currTestHTMLLink = "";
2788N/A //String currTestHTMLLink = arrayData.getTestHTMLLink(i);
2788N/A fwOutput.write(" <testsuite name=\"" + currTestSuite + "\">\n");
2788N/A fwOutput.write(" <purpose>" + arrayData.getTestSuitePurpose(i) + "</purpose>\n");
2788N/A fwOutput.write(" <suiteid>" + arrayData.getTestSuiteID(i) + "</suiteid>\n");
2788N/A fwOutput.write(" <group>" + arrayData.getTestSuiteGroup(i) + "</group>\n\n");
2788N/A
2788N/A fwOutput.write(" <!-- A section describing each testcase-->\n");
2788N/A //System.out.println("arrayData size is " + Integer.toString(arrayData.size()));
2788N/A for(int j = 0; j < arrayData.size(); j++)
2788N/A {
2788N/A //System.out.println("Test Marker is\n" + arrayData.getTestMarker(j));
2788N/A //System.out.println("currTestSuite is\n" + currTestSuite);
2788N/A //System.out.println(" ");
2788N/A if(currTestSuite.indexOf(arrayData.getTestMarker(j)) >= 0)
2788N/A {
2788N/A fwOutput.write(" <testcase name=\"" + arrayData.getTestName(j) + "\">\n");
2788N/A fwOutput.write(" <testid>" + arrayData.getTestID(j) + "</testid>\n");
2788N/A //fwOutput.write(" <testissue>" + arrayData.getTestIssue(j) + "</testissue>\n");
2788N/A fwOutput.write(" <group>" + currTestGroup + "</group>\n");
2788N/A fwOutput.write(" <suite>" + currTestSuite.toString() + "</suite>\n");
2788N/A fwOutput.write(" <purpose>" + arrayData.getTestPurpose(j) + "</purpose>\n");
2788N/A fwOutput.write(" <testscript>\n");
2788N/A fwOutput.write(" <a href=\"" + currTestHTMLLink + "\">" + currTestScript + "</a>\n");
2788N/A fwOutput.write(" </testscript>\n");
2788N/A fwOutput.write(" <steps>\n");
2788N/A fwOutput.write(" <step>\n");
2788N/A fwOutput.write(" " + arrayData.getTestSteps(j) + "\n");
2788N/A fwOutput.write(" </step>\n");
2788N/A fwOutput.write(" </steps>\n");
2788N/A String tmpString = new String(arrayData.getTestPreamble(j));
2788N/A if(tmpString.length() == 0)
2788N/A {
2788N/A fwOutput.write(" <preamble>None</preamble>\n");
2788N/A }
2788N/A else
2788N/A {
2788N/A fwOutput.write(" <preamble>" + tmpString + "</preamble>\n");
2788N/A }
2788N/A tmpString = new String(arrayData.getTestPostamble(j));
2788N/A if(tmpString.length() == 0)
2788N/A {
2788N/A fwOutput.write(" <postamble>None</postamble>\n");
2788N/A }
2788N/A else
2788N/A {
2788N/A fwOutput.write(" <postamble>" + tmpString + "</postamble>\n");
2788N/A }
2788N/A fwOutput.write(" <postamble>" + arrayData.getTestPostamble(j) + "</postamble>\n");
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
2788N/A fwOutput.write(" </testgroup>\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}