/* * 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 legal-notices/CDDLv1_0.txt * or http://forgerock.org/license/CDDLv1.0.html. * 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 legal-notices/CDDLv1_0.txt. * 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 * * * Copyright 2008 Sun Microsystems, Inc. */ import java.io.*; import java.lang.*; import java.util.ArrayList; public class WriteXMLFile_xml { private String group; private ArrayData arrayData; private ArrayList strIndividualSteps; public WriteXMLFile_xml(String inGroup) { group = inGroup; strIndividualSteps = null; } 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); } } String strFilename; 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"; } //System.out.println("Processing: " + strFilename); File fileOutput = new File(strFilename); FileWriter fwOutput = new FileWriter(fileOutput); fwOutput.write("\n\n"); fwOutput.write("\n"); fwOutput.write(" \n"); fwOutput.write(" \n\n"); fwOutput.write(" \n"); fwOutput.write(" \n\n"); fwOutput.write(" \n"); fwOutput.write(" \n"); fwOutput.write(" " + arrayData.getGroupPurpose(0) + "\n"); fwOutput.write(" " + arrayData.getSubgroupName(0) + "\n"); fwOutput.write(" \n"); fwOutput.write(" " + group + "\n"); fwOutput.write(" \n"); fwOutput.write(" \n"); fwOutput.write(" https://opends.dev.java.net\n\n"); fwOutput.write(" \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(" \n"); fwOutput.write(" " + arrayData.getTestSuitePurpose(i) + "\n"); fwOutput.write(" " + arrayData.getTestSuiteID(i) + "\n"); fwOutput.write(" " + arrayData.getTestSuiteGroup(i) + "\n"); fwOutput.write(" \n"); for (int j = 0; j < arrayData.size(); j++) { if (currTestSuite.indexOf(arrayData.getTestMarker(j)) == 0) { fwOutput.write(" \n"); fwOutput.write(" " + arrayData.getTestID(j) + "\n"); fwOutput.write(" " + arrayData.getTestIssue(j) + "\n"); fwOutput.write(" " + currTestGroup + "\n"); fwOutput.write(" " + currTestSuite.toString() + "\n"); fwOutput.write(" " + arrayData.getTestPurpose(j) + "\n"); fwOutput.write(" " + currTestScript + "\n"); fwOutput.write(" \n"); strIndividualSteps = arrayData.getTestSteps(j); for (int j2 = 0; j2 < strIndividualSteps.size(); j2++) { fwOutput.write(" \n"); if (strIndividualSteps.size() > 1) fwOutput.write(Integer.toString(j2 + 1) + ". " + strIndividualSteps.get(j2) + "\n"); else fwOutput.write(strIndividualSteps.get(j2) + "\n"); fwOutput.write(" \n"); } fwOutput.write(" \n"); String tmpString = arrayData.getTestPreamble(j); if (tmpString == null || tmpString.length() == 0) { fwOutput.write(" None\n"); } else { fwOutput.write(" " + tmpString + "\n"); } tmpString = arrayData.getTestPostamble(j); if (tmpString == null || tmpString.length() == 0) { fwOutput.write(" None\n"); } else { fwOutput.write(" " + tmpString + "\n"); } fwOutput.write(" \n"); fwOutput.write(" " + arrayData.getTestResult(j) + "\n"); fwOutput.write(" \n"); fwOutput.write(" \n\n"); } } fwOutput.write(" \n\n"); } fwOutput.write(" \n"); fwOutput.write(" \n"); fwOutput.write(" \n"); fwOutput.write("\n"); fwOutput.close(); } }