com.netriser.xmltestsuite
Class ResourceFactory

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

public class ResourceFactory
extends TestResource

The factory class which handles resource creation and initialisation.

To obtain a resource use @link #getResource(String)

	DBReource dbresource = 
 	(DBResource) ResourceFactory getResource("com.netriser.xmltestsuite.DBResource");
For all the current resources, convenience methods have been added, so this can be simplified to
	DBReource dbresource = ResourceFactory getDbResource()

This package uses a factory pattern to handle resouce creation and initialisation. It ensures that resource objects are created once only, and that the initialisation (setup) and tidyup (teardown) is performed once per run.

This is particularly important when using the gui version of the junit runner,

This factory is designed to be flexible, and can be used to instantiate any class. See @link TestResourceInterface and @link TestResource for more details.

To avoid complex coding in the resource classes to deal with dependancies, resources are inialised by the factory object on a "most recently accessed, inialised first" basis. Whilst not foolproof it works well with existing classes and will work if you follow the guidelines for new classes.


Constructor Summary
ResourceFactory()
           
 
Method Summary
static BrowserResource getBrowserResource()
           
static org.w3c.dom.Document getConfiguration()
           
static DBResource getDBResource()
           
static DomainResource getDomainResource()
           
static HttpResource getHttpResource()
           
static MapResource getMapResource()
           
static TestResourceInterface getResource(java.lang.String className)
           
 TestResourceInterface getResourceByClassName(java.lang.String className)
           
static TestMonitor getTestMonitor()
           
static java.lang.String getText(org.w3c.dom.Node node)
           
static ResourceFactory resourceFactory()
          Method resourceFactory.
 void setTestResult(junit.framework.TestResult testCollector)
          setTestResult.
 void setUp()
          Setup the resource before the tests are run
 void setUp(org.w3c.dom.Document configuration)
           
 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
 

Constructor Detail

ResourceFactory

public ResourceFactory()
Method Detail

setTestResult

public void setTestResult(junit.framework.TestResult testCollector)
setTestResult.

Parameters:
testCollector -

setUp

public void setUp(org.w3c.dom.Document configuration)

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:
TestResourceInterface.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:
TestResourceInterface.tearDown()

getResourceByClassName

public TestResourceInterface getResourceByClassName(java.lang.String className)

resourceFactory

public static ResourceFactory resourceFactory()
Method resourceFactory.

Returns:
ResourceFactory Returns a ResourceFactory singleton

getResource

public static TestResourceInterface getResource(java.lang.String className)

getConfiguration

public static org.w3c.dom.Document getConfiguration()

getDBResource

public static DBResource getDBResource()

getMapResource

public static MapResource getMapResource()

getHttpResource

public static HttpResource getHttpResource()

getTestMonitor

public static TestMonitor getTestMonitor()

getBrowserResource

public static BrowserResource getBrowserResource()

getDomainResource

public static DomainResource getDomainResource()

getText

public static java.lang.String getText(org.w3c.dom.Node node)