|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockcentral.server.MockCentralServer
public class MockCentralServer
The class used to access the Mock Objects and Proxy instances
created within the application. Implemented as a Singleton, this class
provides a number of alternate init methods, which require
either an InputStream, File or file path String to
locate the configuration xml data. Overloaded versions allow the
specification of runtime variables and a boolean indicating whether or not
the InitialContextFactory.getInitialContext() method should
return an instance of MockCentralTestingContext to facilitate
JNDI lookups of Mock Objects.
Any entries in the runtime variables map become available to the Mock Object
building process: if a MethodExpectationBean for a Mock Object
specifies a "variable" value type, the bean's value will be used to look up
an Object from the map, which will then be assigned as the indicated method
parameter or return value. This can be useful if your code under test
accesses runtime data (such as the current date or a value obtained from an
external service) or if you simply want to use a prebuilt Object of any kind
for a method signature part.
The MockCentralTestingContext can be used to automatically bind
Mock Objects under JNDI names for use by code under test: every Mock Object
definition which specifies a jndiName value becomes bindable,
and will be loaded into the Context when the
bindFixtureProxies method is invoked. JNDI names must be unique
within single Fixture instances but may be duplicated across
multiple ones.
| Method Summary | |
|---|---|
void |
addFixture(Fixture fixture)
Adds a new Fixture to the map. |
void |
bindFixtureProxies()
If using the MockCentralTestingContext, gets the current
Fixture and binds all of the Proxy Objects into
the Context which have supplied JNDI names. |
void |
bindFixtureProxies(java.lang.String fixtureName)
If using the MockCentralTestingContext, gets the named
Fixture from the map and binds all of its Proxy
Objects into the Context which have supplied JNDI names. |
javax.naming.Context |
getContext()
Returns the MockCentralTestingContext instance. |
static MockCentralServer |
getInstance()
Returns the Singleton instance. |
java.lang.Object |
getProxy(java.lang.String mockObjectName)
Returns the Proxy for the Mock Object specified by the
argument. |
java.lang.Object |
getProxy(java.lang.String fixtureName,
java.lang.String mockObjectName)
Returns the Proxy for the Mock Object specified by the
arguments. |
void |
init(java.io.File file)
Initializes the application; creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.io.File file,
boolean useTestingContext)
Initializes the application; creates the map to store the Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.File file)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.File file,
boolean useTestingContext)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.InputStream input)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.InputStream input,
boolean useTestingContext)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.lang.String path)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.lang.String path,
boolean useTestingContext)
Initializes the application; stores the map of runtime variables, creates the map to store the Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext. |
void |
init(java.io.InputStream input)
Initializes the application; creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.io.InputStream input,
boolean useTestingContext)
Initializes the application; creates the map to store the Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext. |
void |
init(java.lang.String path)
Initializes the application; creates the map to store the Fixture instances and invokes the
MockDataLoader class to parse the configuration file. |
void |
init(java.lang.String path,
boolean useTestingContext)
Initializes the application; creates the map to store the Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext. |
void |
verifyMock(java.lang.String mockObjectName)
Gets the indicated Mock Object and verifies its expectations. |
void |
verifyMock(java.lang.String fixtureName,
java.lang.String mockObjectName)
Gets the indicated Mock Object from the indicated Fixture
and verifies its expectations. |
void |
verifyMocks()
Gets all the Mock Objects belonging to the current Fixture
and verifies their expectations. |
void |
verifyMocks(java.lang.String fixtureName)
Gets all the Mock Objects belonging to the Fixture defined
by the fixtureName parameter and verifies their
expectations. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static MockCentralServer getInstance()
public void init(java.lang.String path)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
path - the path to the xml config file.
MockCentralServerException - if initialization failed.
public void init(java.io.File file)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
file - the xml config file.
MockCentralServerException - if initialization failed.
public void init(java.io.InputStream input)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
input - the InputStream containing the data.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.lang.String path)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
variablesMap - the map of runtime variables.path - the path to the xml config file.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.File file)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
variablesMap - the map of runtime variables.file - the xml config file.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.InputStream input)
throws MockCentralServerException
Fixture instances and invokes the
MockDataLoader class to parse the configuration file.
variablesMap - the map of runtime variables.input - the InputStream containing the data.
MockCentralServerException - if initialization failed.
public void init(java.lang.String path,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext.
path - the path to the xml config file.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
MockCentralServerException - if initialization failed.
public void init(java.io.File file,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext.
file - the xml config file.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
MockCentralServerException - if initialization failed.
public void init(java.io.InputStream input,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the MockDataLoader
class to parse the configuration file and sets up the
MockCentralTestingContext.
input - the InputStream containing the data.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.lang.String path,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext.
variablesMap - the map of runtime variables.path - the path to the xml config file.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.File file,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext.
variablesMap - the map of runtime variables.file - the xml config file.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
MockCentralServerException - if initialization failed.
public void init(java.util.HashMap<java.lang.String,java.lang.Object> variablesMap,
java.io.InputStream input,
boolean useTestingContext)
throws MockCentralServerException
Fixture instances, invokes the
MockDataLoader class to parse the configuration file and
sets up the MockCentralTestingContext.
variablesMap - the map of runtime variables.input - the
InputStream containing xml config file contents.useTestingContext - flag indicating whether to instruct the
InitialContextFactory to return an instance of the
MockCentralTextingContext class to facilitate jndi lookups
of Mock Objects.
- Throws:
MockCentralServerException - if initialization failed.
public javax.naming.Context getContext()
throws MockCentralServerException
MockCentralTestingContext instance.
Context instance.
MockCentralServerException - if the Context could not
be returned.
public void addFixture(Fixture fixture)
throws MockCentralServerException
Fixture to the map. This method is invoked by the
org.apache.commons.digester.Digester when the configuration
file is parsed, and should not be called by clients.
fixture - the Fixture to add to the map.
MockCentralServerException
public void bindFixtureProxies()
throws MockCentralServerException
MockCentralTestingContext, gets the current
Fixture and binds all of the Proxy Objects into
the Context which have supplied JNDI names. This method is
valid only for configurations that specify only one Fixture
instance.
MockCentralServerException - if the server was not initialized to
use the testing Context or if there was no
Fixture found with the supplied name.
public void bindFixtureProxies(java.lang.String fixtureName)
throws MockCentralServerException
MockCentralTestingContext, gets the named
Fixture from the map and binds all of its Proxy
Objects into the Context which have supplied JNDI names.
fixtureName - the name of the Fixture to load.
MockCentralServerException - if the server was not initialized to
use the testing Context or if there was no
Fixture found with the supplied name.
public java.lang.Object getProxy(java.lang.String mockObjectName)
throws UnknownProxyException,
MockCentralServerException
Proxy for the Mock Object specified by the
argument. This method is valid only for configurations that specify only
one Fixture instance.
mockObjectName - the name under which the Proxy is
stored.
Proxy specified by the argument.
UnknownProxyException - if the Proxy could not be
located.
MockCentralServerException - if there are multiple
Fixture instances defined in the configuration file.
public java.lang.Object getProxy(java.lang.String fixtureName,
java.lang.String mockObjectName)
throws UnknownProxyException
Proxy for the Mock Object specified by the
arguments.
fixtureName - the name of the Fixture containing the
Proxy.mockObjectName - the name under which the Proxy is
stored.
Proxy specified by the arguments.
UnknownProxyException - if the Proxy could not be
located.
public void verifyMocks()
throws MockCentralServerException
Fixture
and verifies their expectations. This method is valid only for
configurations that specify only one Fixture instance.
MockCentralServerException - if there is more than one
Fixture defined in the configuration.
public void verifyMocks(java.lang.String fixtureName)
throws MockCentralServerException
Fixture defined
by the fixtureName parameter and verifies their
expectations.
fixtureName - the name of the Fixture containing the
Mock Objects to be verified.
MockCentralServerException - if the indicated Fixture
does not exist.
public void verifyMock(java.lang.String mockObjectName)
throws UnknownProxyException,
MockCentralServerException
Fixture instance.
mockObjectName - the name of the Mock Object.
UnknownProxyException - if the Mock Object's Proxy
could not be located.
MockCentralServerException - if there are multiple fixtures
definged in the configuration file.
public void verifyMock(java.lang.String fixtureName,
java.lang.String mockObjectName)
throws UnknownProxyException
Fixture
and verifies its expectations.
fixtureName - the name of the Fixture containing the
Mock Object.mockObjectName - the name of the Mock Object.
UnknownProxyException - if the Mock Object's Proxy
could not be located.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||