|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockcentral.server.Fixture
public class Fixture
A class used to build and group Mock Objects and Proxy instances
accessible to the MockCentralServer. This class serves several
purposes: it allows for organization of Mock Object definitions into
logical collections, for verifying expectations on all such definitions in
one step, and for specifying a distinct group of objects to be bound into the
MockCentralTestingContext under their supplied JNDI names with
one call to the server. A collection of simple (non-Mock) objects which are
additionally to be bound into the context are also associated with individual
instances of this class, and are loaded along with the Proxy
instances. All JNDI names should be unique within each Fixture.
Instances may declare that they import other instances, inheriting all of
their Mock Object and simple (non-Mock) JNDI-bound object definitions, which
will be added at runtime. Note that an exception will be thrown if there are
circular references within the imports list. Also note that if there are
duplicated JNDI names among JNDI-bound objects inherited from different
Fixture instances, the "last-built" object will be the one
finally bound under the name. Since the build order of inherited
Fixture instances is determined dynamically by the server, the
result will not
necessarily be from the last or latest Fixture in your
imports list. The logger will post a warning when a binding is overridden.
This class accepts MockObjectSetup and
SimpleBoundObjectBean instances built within the
MockDataLoader for use in constructing the maps of Mocks and
simple objects and performs validation to assure that the Mock Object
definitions do not contain circular references. The "add" and "set" methods
defined in this class are invoked by the
org.apache.commons.digester.Digester when the configuration file
is parsed, and should not be called by clients.
| Constructor Summary | |
|---|---|
Fixture()
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
addImport(java.lang.String importedFixtureName)
Adds the supplied Fixture name to the list of names of
Fixture instances imported by this instance. |
void |
addMockObjectSetup(MockObjectSetup mockObjectSetup)
Adds the supplied MockObjectSetup to the list from which the
Mocks and Proxy objects will be created. |
void |
addSimpleBoundObject(SimpleBoundObjectBean bean)
Creates and adds a simple (non-Mock) object to map of JNDI-bound objects. |
protected static java.lang.String |
getCurrentFixtureName()
Returns the name of the Fixture currently being created. |
java.lang.String |
getFixtureDescription()
Returns the description of this instance. |
java.lang.String |
getFixtureName()
Returns the name of this instance. |
java.util.ArrayList<java.lang.String> |
getImportedFixtureNames()
Returns the list of names of Fixture instances imported by
this instance. |
java.util.HashMap<java.lang.String,java.lang.Object> |
getJNDIBoundObjectsMap()
Returns the map of Proxy objects and simple(non-Mock)
objects used in this Fixture that will be bound under a JNDI
name in the MockCentralTestingContext. |
java.util.HashMap<java.lang.String,com.mockobjects.dynamic.Mock> |
getMockObjectsMap()
Returns the map of the Mock Objects used in this instance. |
java.util.HashMap<java.lang.String,java.lang.Object> |
getProxiesMap()
Returns the map of Proxy objects for the Mock objects used
in this instance. |
java.lang.Object |
getProxy(SignaturePartBean bean)
Returns the Proxy stored under the name matching the value
field of the supplied SignaturepartBean. |
void |
loadImports()
Processes the list of imported Fixture instances to add the
Mock Objects, Proxy objects and simple (non-Mock) JNDI-bound
objects of each imported Fixture to the maps in this
instance. |
void |
processMockObjectSetups()
Processes the list of MockObjectSetup instances to create
the Mocks and Proxy objects, adding them to the appropriate
maps defined in this class. |
void |
setFixtureDescription(java.lang.String fixtureDescription)
Sets the description of this instance. |
void |
setFixtureName(java.lang.String fixtureName)
Sets the name of this instance. |
java.lang.String |
toString()
|
void |
verifyMockObject(java.lang.String mockObjectName)
Calls the Mock.verify method on the indicated Mock to verify
that its expected methods were called. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Fixture()
| Method Detail |
|---|
public void setFixtureName(java.lang.String fixtureName)
fixtureName - the name of this instance.public java.lang.String getFixtureName()
public void setFixtureDescription(java.lang.String fixtureDescription)
fixtureDescription - the description to set.public java.lang.String getFixtureDescription()
public void addImport(java.lang.String importedFixtureName)
Fixture name to the list of names of
Fixture instances imported by this instance.
importedFixtureName - the name of the Fixture to add to the list.public java.util.ArrayList<java.lang.String> getImportedFixtureNames()
Fixture instances imported by
this instance.
Fixture instances imported by
this instance.public void loadImports()
Fixture instances to add the
Mock Objects, Proxy objects and simple (non-Mock) JNDI-bound
objects of each imported Fixture to the maps in this
instance.
public void addSimpleBoundObject(SimpleBoundObjectBean bean)
throws MockCentralServerException
SimpleBoundObjectBean is used to assign the
JNDI name and build the object itself.
bean - the SimpleBoundObjectBean to add.
MockCentralServerException - if the object could not be constructed.public java.util.HashMap<java.lang.String,com.mockobjects.dynamic.Mock> getMockObjectsMap()
mockObjectName field values defined in each
MockObjectSetup added to this Fixture.
Fixture.public java.util.HashMap<java.lang.String,java.lang.Object> getProxiesMap()
Proxy objects for the Mock objects used
in this instance. The keys are the mockObjectName field
values defined in each MockObjectSetup added to this
Fixture.
Proxy objects for the Mock objects used in
this instance.public java.lang.Object getProxy(SignaturePartBean bean)
Proxy stored under the name matching the value
field of the supplied SignaturepartBean.
bean - the SignaturepartBean.
Proxy stored under the name matching the value
field of the supplied SignaturepartBean.public java.util.HashMap<java.lang.String,java.lang.Object> getJNDIBoundObjectsMap()
Proxy objects and simple(non-Mock)
objects used in this Fixture that will be bound under a JNDI
name in the MockCentralTestingContext. The keys are the
jndiName field values defined in each
MockObjectSetup or SimpleBoundObject added to
this Fixture.
Proxy objects for the Mock objects used in
this instance that will be bound under a JNDI name in the
MockCentralTestingContext .public void addMockObjectSetup(MockObjectSetup mockObjectSetup)
MockObjectSetup to the list from which the
Mocks and Proxy objects will be created.
mockObjectSetup - the MockObjectSetup to add.
public void processMockObjectSetups()
throws MockCentralServerException
MockObjectSetup instances to create
the Mocks and Proxy objects, adding them to the appropriate
maps defined in this class. The processIncompleteSetups
method is invoked after the list has been iterated through to process any
instances that could not be processed the first time through because they
contained references to other Mock Objects not yet created.
MockCentralServerException - if a MockObjectSetup could not be processed.public void verifyMockObject(java.lang.String mockObjectName)
Mock.verify method on the indicated Mock to verify
that its expected methods were called.
mockObjectName - the name of the Mock Object to verify.public java.lang.String toString()
toString in class java.lang.Objectprotected static java.lang.String getCurrentFixtureName()
Fixture currently being created.
Fixture currently being created.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||