GenerateOpenDSTestSpecs.java revision b4bae64723d5797ec0658312f2212dc97bf3c571
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * CDDL HEADER START
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * The contents of this file are subject to the terms of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Common Development and Distribution License, Version 1.0 only
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * (the "License"). You may not use this file except in compliance
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * with the License.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * You can obtain a copy of the license at
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * trunk/opends/resource/legal-notices/OpenDS.LICENSE
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * See the License for the specific language governing permissions
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * and limitations under the License.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * When distributing Covered Code, include this CDDL HEADER in each
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * file and include the License file at
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * add the following below this CDDL HEADER, with the fields enclosed
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * by brackets "[]" replaced with your own identifying information:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Portions Copyright [yyyy] [name of copyright owner]
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * CDDL HEADER END
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Portions Copyright 2007 Sun Microsystems, Inc.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // retrieve input
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // validate input
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("Using file directory, " + strParentDirName);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("Using output directory, " + strOutputDirName);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // java files are assumed to be from the unit-integration tests.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // xml files are assumed to be from the functional tests.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync if((strFileFormat.startsWith("java")) || (strFileFormat.startsWith("xml")))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("Using file format " + strFileFormat.toString());
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync fatalMsg(strFileFormat + " is not supported in this version");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // create list of files to parse
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync TestFileList listFiles = new TestFileList(strParentDirName);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // clean out the list of files
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // The ArrayList object, arrayFiles, contains the list of files that must be parsed.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // print out list of files
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync //for(int i=0; i<arrayFiles.size(); i++)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // File gotFile = (File)(arrayFiles.get(i));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // System.out.println("File number " + Integer.toString(i) + " is " + gotFile.toString());
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // The ArrayList object, arrayDirs, contains the list of directories where the files will be found.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // print out list of directories
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync //for(int i=0; i<arrayDirs.size(); i++)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // File gotDir = (File)(arrayDirs.get(i));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // System.out.println("Directory number " + Integer.toString(i) + " is " + gotDir.toString());
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // Assume each directory will result in an output xml file
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // There will be one ParseData object for each directory.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // Each ParseData object holds the test specs for all tests in that directory.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // The ArrayList object, arrayTests, contains all the ParseData objects.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ArrayList <Object>arrayTests = new ArrayList<Object>();
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // For each directory, parse out the data from each file within that directory.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // parse out data from all java files in a directory
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync String parsedDir = parseSuite(gotDir, strParentDirName);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ParseData parseData = new ParseData(parsedDir, strFileFormat);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync arrayTests.add((ArrayData)(parseData.ParseFile(parsedDir, arrayFiles, strParentDirName)));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync // create the output xml files from the ParsedData objects
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ArrayData arrayData = (ArrayData)(arrayTests.get(i));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync WriteXMLFile_int xmlFile = new WriteXMLFile_int(arrayData.getTestSuite(0));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync WriteXMLFile_xml xmlFile = new WriteXMLFile_xml(arrayData.getTestSuite(0));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("Files successfully written to the output directory.");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync private static void usage()
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("This program will parse files that are used for testing and create an xml file that is used for generating test specification html pages.");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("The program will recursively search for files from the directory that is passed in from the parameter.");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("This version will only recursively search one or two levels below the \"directory to files\" which is passed in as a parameter.");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println("The file formats that are currently supported are \"java\" and \"xml\".");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync System.out.println(" java GenerateOpenDSTestSpecs [directory to files] [directory for output files] [file format]");
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync private static String parseSuite(File inDir, String strParentDir)