Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21295/javasrc/biz/xsoftware/mock2
Added Files:
Behavior.java CalledMethod.java MockObject.java
MockObjectFactory.java
Log Message:
add api we are implementing.
--- NEW FILE: Behavior.java ---
package biz.xsoftware.mock2;
/**
* A marker interface that signifies that the implementation is a behavior
* and cloner class. Methods for the behavior has the exact same signature as the
* method. The cloner method has the <methodName>Clone with the same signature
* as the method to clone the parameters and returns the cloned parameters as
* an object array.
*
* @author Dann Ormond
*
*/
public interface Behavior {
}
--- NEW FILE: CalledMethod.java ---
package biz.xsoftware.mock2;
/**
* A representation of a called method. This bean holds the parameters,
* method name, and the stack trace for a specific invocation of a method.
*
* @author Dann Ormond
*
*/
public interface CalledMethod {
public String getMethodName();
public Object[] getParameters();
public String getStackTrace();
}
--- NEW FILE: MockObject.java ---
package biz.xsoftware.mock2;
/**
*
* @author Dann Ormond
*
*/
public interface MockObject {
/**
* Expect a method to be called with no return value. The default timeout is
* 10 seconds.
*
* @param methodName
* the name of the method to expect
* @param vargs
* the optional parmeter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, Class[] vargs);
/**
* Expect a method to be called an returning the specified return value. The
* default timeout is 10 seconds.
*
* @param returnValue
* the value to return from the method call
* @param methodName
* the name of the method to expect
* @param vargs
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(Object returnValue, String methodName,
Class[] vargs);
/**
* Expect a method to be called an throw an exception rather than return
* normal. The default timeout is 10 seconds.
*
* @param methodName
* the name of the method to expect
* @param throwable
* the exception to throw from the method
* @param vargs
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, Throwable throwable,
Class[] vargs);
/**
* Expect a method to be called with the specified behavior to modify the
* parameters and return value as needed. The default timeout is 10 seconds.
*
* @param methodName
* the name of the method to expect
* @param behavior
* the behavior to handle cloning managing of the return value
* @param params
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, Behavior behavior,
Class[] params);
/***************************************************************************
* SAME METHODS AS ABOVE BUT WITH TIMEOUT PARAMETER
**************************************************************************/
/**
* Expect a method to be called with no return value.
*
* @param methodName
* the name of the method to expect
* @param timeout
* The time to wait for method to be called before failing test
* @param vargs
* the optional parmeter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, long timeout, Class[] vargs);
/**
* Expect a method to be called an returning the specified return value.
*
* @param returnValue
* the value to return from the method call
* @param methodName
* the name of the method to expect
* @param timeout
* The time to wait for method to be called before failing test
* @param vargs
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(Object returnValue, String methodName,
long timeout, Class[] vargs);
/**
* Expect a method to be called an throw an exception rather than return
* normal.
*
* @param methodName
* the name of the method to expect
* @param throwable
* the exception to throw from the method
* @param timeout
* The time to wait for method to be called before failing test
* @param vargs
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, Throwable throwable,
long timeout, Class[] vargs);
/**
* Expect a method to be called with the specified behavior to modify the
* parameters and return value as needed.
*
* @param methodName
* the name of the method to expect
* @param behavior
* the behavior to handle cloning managing of the return value
* @param timeout
* The time to wait for method to be called before failing test
* @param params
* the optional parameter types of the method call
* @return the CalledMethod information that will be filled after the method
* is called
*/
public CalledMethod expect(String methodName, Behavior behavior,
long timeout, Class[] params);
/**
* Verifies that the expected methods are called within the timeout.
*/
public void verify();
/**
* Add a method to the ignore list.
*
* @param methodName
* the name of the method to ignore
* @param vargs
* the optional parameter types of the method call
*/
public void addIgnoreMethod(String methodName, Class[] vargs);
/**
* Remove a method from the ignore list.
*
* @param methodName
* the name of the method to ignore
* @param vargs
* the optinal parameter types of the method call
*/
public void removeIgnoreMethod(String methodName, Class[] vargs);
/**
* Sets the default return value for a method call and adds the method to
* the ignore list.
*
* @param returnValue
* the value to return for specific method calls
* @param methodName
* the name of the method
* @param vargs
* the optional parameter types of the method calls
*/
public void setDefaultReturnValue(Object returnValue, String methodName,
Class[] vargs);
/**
* Creates returns an instance of the mocked object.
*
* @return an instance of the mocked object
*/
public Object instance();
}
--- NEW FILE: MockObjectFactory.java ---
package biz.xsoftware.mock2;
/**
* The factory class that creates MockObjects
*
* @author Dann Ormond
*
*/
public abstract class MockObjectFactory {
public static MockObject createMock(Class[] interfacesToMock) {
// TODO: Implement me!
return null;
}
public static MockObject createMock(Class interfaceToMock) {
return createMock(new Class[] { interfaceToMock });
}
public static MockObject createMock(Class interfaceToMock, Object realObject) {
// TODO: Implement me!
return null;
}
}
|