junit.extensions.jfcunit.tools
Class XMLRoot

java.lang.Object
  extended byjunit.framework.TestSuite
      extended byjunit.extensions.xml.XMLTestSuite
          extended byjunit.extensions.jfcunit.tools.XMLRoot
All Implemented Interfaces:
IXMLTest, IXMLTestSuite, junit.framework.Test, XMLConstants

public class XMLRoot
extends XMLTestSuite

Title: JFCUnit

Description: This class is a tool class which interfaces a JUnit test environment to the JFCUnits XML test environment. The application can be passed through system properties, the constructor, the static call to get the test suite, or through the main methods arguments. When XMLRoot is instanciated with no arguments then the following system properties are queried. jfcunit.xmlroot.classname required main classname. jfcunit.xmlroot.args optional parameters to the main method. jfcunit.xmlroot.testsuite XML test suite to be run. jfcunit.xmlroot.record If not specified the record tags will be ignored. jfcunit.xmlroot.create Create a new xml file if it does not exist.

Version:
1.0
Author:
kevin wilson

Field Summary
static java.lang.String DOCUMENT_FACTORY
          Document factory to be used as default.
static java.lang.String XMLROOT_ARGS
          System property for args.
static java.lang.String XMLROOT_CLASSNAME
          System property for classname.
static java.lang.String XMLROOT_CREATE
          System property for create the xml root.
static java.lang.String XMLROOT_RECORD
          System property for recording.
static java.lang.String XMLROOT_TESTSUITE
          System property for XML file.
 
Fields inherited from class junit.extensions.xml.XMLTestSuite
 
Fields inherited from class junit.framework.TestSuite
 
Fields inherited from interface junit.extensions.xml.XMLConstants
ACTION, ACTUALOBJ, ACTUALREFID, ADD, ASSERTENABLED, ASSERTEQUALS, ASSERTNOTEQUALS, ASSERTNOTNULL, ASSERTNOTSAME, ASSERTNULL, ASSERTSAME, CALL, CASE, CHOOSE, CLASSNAME, COLUMN, CONFIRM, DEBUG, DEFAULT, DELIMITER, DIALOG, DUMP, ECHO, ENABLED, ENCODING, EVALUATE, EXPECTEDOBJ, EXPECTEDREFID, FAIL, FILE, FOCUS, FOREACH, ID, INDEX, JFCFILELOC, LESSTHAN, LISTITEM, LOG, MARK, MESSAGE, METHOD, MODE, NAME, OTHERWISE, PATHREFID, PROCEDURE, PROPERTY, RECURSIVE, REFID, RELATIVE, REMOVE, ROW, SAVE, STDERR, STDOUT, STOPWATCH, SUITE, SWITCH, TABLECELL, TAGHANDLERS, TAGNAME, TEST, TYPE, USERE, VALUE, WHEN, WHILE
 
Constructor Summary
XMLRoot()
          Default constructor.
XMLRoot(java.lang.String classname, java.lang.String[] args, java.lang.String filename)
          Default constructor.
 
Method Summary
protected static java.lang.String[] getArgs()
          Get the jfcunit.xmlroot.args system property.
protected static java.lang.String getClassName()
          Get the jfcunit.xmlroot.classname system property.
protected static java.lang.String getCommand(java.lang.String classname, java.lang.String[] args)
          Assembles the classname and args into one string.
protected static boolean getCreate()
          Get the XML file name from the jfcunit.xmlroot.create system property.
protected static java.io.InputStream getInputStream(java.lang.String classname, java.lang.String[] args, java.lang.String fileName)
          Get the input stream for the XML file.
protected static boolean getRecord()
          Get the state of the jfcunit.xmlroot.record system property.
protected static java.lang.String getTestSuite()
          Get the XML file name from the jfcunit.xmlroot.testsuite system property.
static void main(java.lang.String[] args)
          Application start method.
static junit.framework.Test suite()
          Creates a new test suite based on the system properties.
static junit.framework.Test suite(java.lang.String classname, java.lang.String[] args, java.lang.String filename)
          Creates a new test suite based on the main class and filename provided.
private static void updateDocFactory()
          Set the document factory if it is not set for java versions less than 1.4.
 
Methods inherited from class junit.extensions.xml.XMLTestSuite
addFile, addProcedure, addProperty, addTest, clearProperties, getDebug, getFileName, getProcedure, getProcedureCache, getProperty, getPropertyCache, getPropertyName, getPropertyNames, removeProperty, resolveProperties, setParent
 
Methods inherited from class junit.framework.TestSuite
addTestSuite, countTestCases, createTest, getName, getTestConstructor, run, runTest, setName, testAt, testCount, tests, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface junit.framework.Test
countTestCases, run
 

Field Detail

DOCUMENT_FACTORY

public static final java.lang.String DOCUMENT_FACTORY
Document factory to be used as default.

See Also:
Constant Field Values

XMLROOT_CLASSNAME

public static final java.lang.String XMLROOT_CLASSNAME
System property for classname.

See Also:
Constant Field Values

XMLROOT_ARGS

public static final java.lang.String XMLROOT_ARGS
System property for args.

See Also:
Constant Field Values

XMLROOT_RECORD

public static final java.lang.String XMLROOT_RECORD
System property for recording.

See Also:
Constant Field Values

XMLROOT_TESTSUITE

public static final java.lang.String XMLROOT_TESTSUITE
System property for XML file.

See Also:
Constant Field Values

XMLROOT_CREATE

public static final java.lang.String XMLROOT_CREATE
System property for create the xml root.

See Also:
Constant Field Values
Constructor Detail

XMLRoot

public XMLRoot()
        throws java.lang.Exception
Default constructor. Uses system properties to get the classname and testsuite filename.

Throws:
java.lang.Exception - may be thrown.

XMLRoot

public XMLRoot(java.lang.String classname,
               java.lang.String[] args,
               java.lang.String filename)
        throws java.lang.Exception
Default constructor.

Parameters:
classname - Class name of the main application class
args - Arguments to be passed to the main method.
filename - The filename of the XML test suite specification
Throws:
java.lang.Exception - may be thrown.
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Application start method. The application takes two arguments: >main class< The Main class of the application to test >test suite specification< The XML file containing the test suite

Parameters:
args - classname [args...] xmlfile
Throws:
java.lang.Exception - may be thrown.

suite

public static junit.framework.Test suite()
                                  throws java.lang.Exception
Creates a new test suite based on the system properties.

Returns:
Test generated from the System properties.
Throws:
java.lang.Exception - may be thrown.

suite

public static junit.framework.Test suite(java.lang.String classname,
                                         java.lang.String[] args,
                                         java.lang.String filename)
                                  throws java.lang.Exception
Creates a new test suite based on the main class and filename provided.

Parameters:
classname - Class name of the main application class
args - Arguments to be passed to the application.
filename - Name of XML file containing test suite
Returns:
Test created with the given arguments.
Throws:
java.lang.Exception - may be thrown.

getArgs

protected static final java.lang.String[] getArgs()
Get the jfcunit.xmlroot.args system property.

Returns:
Arguments to be run with the command. Assumes space separated list. May not work for all cases of program arguments.

getClassName

protected static final java.lang.String getClassName()
Get the jfcunit.xmlroot.classname system property.

Returns:
class name to be executed.

getCommand

protected static final java.lang.String getCommand(java.lang.String classname,
                                                   java.lang.String[] args)
Assembles the classname and args into one string.

Parameters:
classname - program name.
args - Arguments used.
Returns:
Program and arguments.

getCreate

protected static final boolean getCreate()
Get the XML file name from the jfcunit.xmlroot.create system property.

Returns:
true if the xml file should be created.

getInputStream

protected static java.io.InputStream getInputStream(java.lang.String classname,
                                                    java.lang.String[] args,
                                                    java.lang.String fileName)
Get the input stream for the XML file. If a XML file cannot be found then a template will be generated for recording.

Parameters:
classname - Classname added to template.
args - Arguments to be added to the template.
fileName - XML file name to be opened or created.
Returns:
Input stream of the file opened.

getRecord

protected static final boolean getRecord()
Get the state of the jfcunit.xmlroot.record system property.

Returns:
true if the record element is present and set to true.

getTestSuite

protected static final java.lang.String getTestSuite()
Get the XML file name from the jfcunit.xmlroot.testsuite system property.

Returns:
XML file name.

updateDocFactory

private static void updateDocFactory()
Set the document factory if it is not set for java versions less than 1.4.



Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999