com.netriser.xmltestsuite
Class ConfigurationResource

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--com.netriser.xmltestsuite.TestResource
              |
              +--com.netriser.xmltestsuite.ConfigurationResource
All Implemented Interfaces:
TestResourceInterface

public class ConfigurationResource
extends TestResource

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

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.
static void setPathname(java.lang.String s)
          sets the default xml pathname
 void setUp()
          Setup the resource before the tests are run
 void tearDown()
          Tidy up the resource after the tests are run
 
Methods inherited from class com.netriser.xmltestsuite.TestResource
debug, getDebugMode, getVerboseMode, setDebug, setVerbose, useTestResult, verbose
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPathname

public static void setPathname(java.lang.String s)
sets the default xml pathname


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

setUp

public void setUp()
Description copied from class: TestResource
Setup the resource before the tests are run

Specified by:
setUp in interface TestResourceInterface
Specified by:
setUp in class TestResource
See Also:
TestResource.setUp()

tearDown

public void tearDown()
Description copied from class: TestResource
Tidy up the resource after the tests are run

Specified by:
tearDown in interface TestResourceInterface
Specified by:
tearDown in class TestResource
See Also:
TestResource.tearDown()

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 -