com.netriser.xmltestsuite
Class MapResource

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

public class MapResource
extends TestResource

Provides a variables mechanism for test objects.

It allows values to be associated with a name. These are stored in a map. A search and replace is performed on test data, replacing strings of the form #{name} with stored values.

This class is used by most of the test classes.


Constructor Summary
MapResource()
           
 
Method Summary
 boolean containsKey(java.lang.String key)
           
 java.lang.String get(java.lang.String key)
           
 java.lang.String get(java.lang.String key, com.meterware.httpunit.WebResponse wr)
           
 java.util.HashMap getMap()
          Provides access to the map object.
 java.lang.String getRegex(java.lang.String s)
          Replaces any variables in the input string with their current values.
 java.lang.String getRegex(java.lang.String s, com.meterware.httpunit.WebResponse wr)
           
 java.lang.Object put(java.lang.String key, java.lang.String value)
           
 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
 

Constructor Detail

MapResource

public MapResource()
Method Detail

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()

getRegex

public java.lang.String getRegex(java.lang.String s)
Replaces any variables in the input string with their current values. Used e.g. to insert database identities into urls or form fields

Parameters:
s - Input string with variables of the form #{uniqueName}
Returns:
String with variables replaced by current values
Throws:
java.lang.Exception - Raised if variable has no current value
Since:

getRegex

public java.lang.String getRegex(java.lang.String s,
                                 com.meterware.httpunit.WebResponse wr)

get

public java.lang.String get(java.lang.String key)
See Also:
Map.get(Object)

get

public java.lang.String get(java.lang.String key,
                            com.meterware.httpunit.WebResponse wr)

put

public java.lang.Object put(java.lang.String key,
                            java.lang.String value)
See Also:
Map.put(Object,Object)

containsKey

public boolean containsKey(java.lang.String key)
See Also:
Map.containsKey(Object)

getMap

public java.util.HashMap getMap()
Provides access to the map object. For use when the statndard accessor methods is insufficient.

Returns:
HashMap