com.netriser.xmltestsuite
Class TestFactory

java.lang.Object
  |
  +--com.netriser.xmltestsuite.TestFactory

public class TestFactory
extends java.lang.Object

Provides configuration data and test objects generated an xml file.

Provides the configuration as a resource to other objects. Instantiates test objects from a specified node in the xml input file The default xml pathname is defined by the property ConfigurationResource.file or test.xml

This class is instantiated as a singleton using a factory To obtain a instance use

 	ConfigurationResource ResourceFactory.getConfigurationResource();
 

Author:
david

Constructor Summary
TestFactory(java.io.File xmlFile)
          Reads the xml configuration file.
 
Method Summary
 org.w3c.dom.Document getConfiguration()
          Returns the current xml document
 org.w3c.dom.Element getTopElement()
          Returns the top element in the current xml document
 void instatiateTestObjects(org.w3c.dom.Element stepElement, junit.framework.TestSuite parent)
          Instatiate java objects based on the tree of elements whose root is the parameter stepElement.
 void instatiateTestObjects(junit.framework.TestSuite parent, java.lang.String xmlTestRootName)
          Instatiate java objects based on the tree of elements whose root is the first element which matches the parameter xmlTestRootName, typically testSuite.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestFactory

public TestFactory(java.io.File xmlFile)
Reads the xml configuration file. This class is instantiated as a singleton using a factory To obtain a instance use
 	ConfigurationResource ResourceFactory.getConfigurationResource();
 

Method Detail

getConfiguration

public org.w3c.dom.Document getConfiguration()
Returns the current xml document

Returns:
Document

getTopElement

public org.w3c.dom.Element getTopElement()
Returns the top element in the current xml document

Returns:
Element

instatiateTestObjects

public void instatiateTestObjects(junit.framework.TestSuite parent,
                                  java.lang.String xmlTestRootName)
Instatiate java objects based on the tree of elements whose root is the first element which matches the parameter xmlTestRootName, typically testSuite.

Parameters:
parent -
xmlTestRootName -

instatiateTestObjects

public void instatiateTestObjects(org.w3c.dom.Element stepElement,
                                  junit.framework.TestSuite parent)
Instatiate java objects based on the tree of elements whose root is the parameter stepElement. This method assumes that the xml document has been validated against e.g. a dtd This dtd should define the valid elements, attributes and containment hierarchy, to ensure that this method doesn't try to instantiate invalid objects. Fail exceptions are raised if there is a mismatch between the xml and the available java classes If the element is called myobject the class myobject will be instantiated 'myobject' must have a constructor myobject(String name). This object would typically inherit directly or indirectly from a junit class To simplify the xml, if the specified class doesn't exist com.netriser.xmltestsuite.testcases is prepended to the class name i.e. myobject maps to firstly to the class myobject or secondly com.netriser.xmltestsuite.testcases.myobject If the xml element has descendent elements, these will also be instantiated. This requires the current object to be derived from the class TestSuite For every attribute of the xml attribute,the java objects attribute will be set there must exist a function public void 'setMyattriibute(String) The java objects name is taken from the element attribute stepid (if it exists) or is derived from other attributes, the objects class and the name of the elements parent If the class inherits from the interface XmlElement, setXmlElement(Element) is used so that the class can access the xml from which it was created

Parameters:
stepElement -
parent -