|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.xsoftware.mock.client.JsMockSuperclass
public abstract class JsMockSuperclass
This is a super class for mock Objects. It has the following options
public final static ACTION_METHOD = "actionPerformed method"; public void actionPerformed(ActionEvent evt) { super.methodCalled(ACTION_METHOD, evt); }In the test, when you expect an ActionEvent, you can call
Object o = MockActionListener.expectEvent(ACTION_METHOD); ActionEvent evt = (ActionEvent)evt; assertNonNull(evt.getSource());Another useful behavior is throwing any type of exception using setExceptionOnMethod(String method, Throwable e). This can test robustness in a system to make sure listeners or services that throw exceptions don't affect your system, or at least affect your system in the proper way.
Field Summary | |
---|---|
static int |
DEFAULT_WAIT_TIME
Default wait time to wait for a method to be called once expectCall is called. |
Fields inherited from interface biz.xsoftware.mock.client.JsMockObject |
---|
ANY, NONE |
Constructor Summary | |
---|---|
JsMockSuperclass()
Default constructor of superclass of all mockObjects with a delay of 10 seconds. |
|
JsMockSuperclass(int delay)
The constructor to use to override the default delay( DEFAULT_WAIT_TIME )
such that the mock object will give methods a longer time to be called
before timing out to fail the test. |
|
JsMockSuperclass(String id)
|
Method Summary | |
---|---|
void |
addBehavior(String method,
JsBehavior behavior)
|
void |
addIgnore(String method)
When calling expect, the MockObject will ignore this method, so it will not result in an exception. |
void |
addReturnValue(String method,
Object o)
Add a return value to return when 'method' is called. |
void |
addThrowException(String method,
Throwable e)
Add an exception to throw when a method on the mockObject is called. |
JsCalledMethod |
expect(String method)
Waits for one and only one method to be called. |
JsCalledMethod[] |
expect(String[] methods)
Waits for all the methods to be called. |
int |
getExpectTimeout()
|
void |
removeIgnore(String method)
Removes the method from the ignored methods set. |
void |
setDefaultReturnValue(String method,
Object o)
Set the DefaultReturnValue for a 'method' |
void |
setExpectTimeout(int delay)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_WAIT_TIME
Constructor Detail |
---|
public JsMockSuperclass()
public JsMockSuperclass(int delay)
DEFAULT_WAIT_TIME
)
such that the mock object will give methods a longer time to be called
before timing out to fail the test.
delay
- The amount of time in milliseconds to wait for a method to be
called.public JsMockSuperclass(String id)
Method Detail |
---|
public void setExpectTimeout(int delay)
setExpectTimeout
in interface JsMockObject
public int getExpectTimeout()
getExpectTimeout
in interface JsMockObject
public void addIgnore(String method)
JsMockObject
addIgnore
in interface JsMockObject
public void removeIgnore(String method)
JsMockObject
removeIgnore
in interface JsMockObject
public JsCalledMethod expect(String method)
JsMockObject
expect
in interface JsMockObject
method
- The expected method.
biz.xsoftware.mock.JsMockObject#expect(java.lang.String)
public JsCalledMethod[] expect(String[] methods)
JsMockObject
expect
in interface JsMockObject
methods
- The expected method(s) in the correct order.
biz.xsoftware.mock.JsMockObject#expect(java.lang.String[])
public void addThrowException(String method, Throwable e)
JsMockObject
addThrowException
in interface JsMockObject
method
- The method to throw the exception on when it is called.e
- The exception to throw on method.biz.xsoftware.mock.JsMockObject#addThrowException(java.lang.String, java.lang.Throwable)
public void addReturnValue(String method, Object o)
JsMockObject
addReturnValue
in interface JsMockObject
method
- The method that when called returns first value on queueo
- The object to return that is added to the queuebiz.xsoftware.mock.JsMockObject#addReturnValue(java.lang.String, java.lang.Object)
public void setDefaultReturnValue(String method, Object o)
JsMockObject
setDefaultReturnValue
in interface JsMockObject
method
- The methodpublic void addBehavior(String method, JsBehavior behavior)
addBehavior
in interface JsMockObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |