com.agical.rmock.extension.junit
Class RMockTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.agical.rmock.extension.junit.AbstractStrategyTestCase
              extended by com.agical.rmock.extension.junit.BasicJUnitStrategyTestCase
                  extended by com.agical.rmock.extension.junit.AbstractMockStrategyTestCase
                      extended by com.agical.rmock.extension.junit.RMockTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
RMockServiceFactoryTestCase

public abstract class RMockTestCase
extends AbstractMockStrategyTestCase

(c) Agical AB 2005

Author:
joakim.ohlrogge

Field Summary
protected  IteratorFactory all
           
protected  DocumentationControl doc
           
protected  MultiplicityFactory expect
           
protected  MatchActionFactory matchAction
           
protected  SectionFactory s
           
 
Fields inherited from class com.agical.rmock.extension.junit.AbstractStrategyTestCase
is
 
Constructor Summary
  RMockTestCase()
           
protected RMockTestCase(Hub hub, java.lang.String name)
           
protected RMockTestCase(java.lang.String name)
           
 
Method Summary
 void appendToSection(java.lang.String id)
           
 void beginSection(Section section)
           
protected  TestStep createStrategy(java.lang.String test)
          Implement this method to return a strategy to run for the given test.
protected  void endSection()
           
 void expectThatExceptionThrown(Expression exceptionExpression)
          Sets up that an exception is expected to be thrown as a result of this testCase.
protected  java.lang.Object fakeAndIntercept(java.lang.Class itf)
          Fake and intercept is meant to be used on interfaces.
protected  java.lang.Object fakeAndIntercept(java.lang.Class itf, java.lang.String id)
          Fake and intercept is meant to be used on interfaces.
protected  CollectionSelector forEach(Expression expression)
           
protected  ExceptionVerifier getExceptionVerifier()
           
protected  java.lang.Object intercept(java.lang.Class clazz)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object intercept(java.lang.Class clazz, java.lang.Class[] signature, java.lang.Object[] arguments)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object intercept(java.lang.Class clazz, java.lang.Class[] signature, java.lang.Object[] arguments, java.lang.String id)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object intercept(java.lang.Class clazz, java.lang.Object[] arguments)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object intercept(java.lang.Class clazz, java.lang.Object[] arguments, java.lang.String id)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object intercept(java.lang.Class clazz, java.lang.String id)
          intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance.
protected  java.lang.Object mock(java.lang.Class clazz)
          Creates a mock for the selected class.
protected  java.lang.Object mock(java.lang.Class clazz, java.lang.Class[] signature, java.lang.Object[] args, java.lang.String id)
          Creates a mock for the selected class with the specified id, using the specified args using the constructor with the specified signature.
protected  java.lang.Object mock(java.lang.Class clazz, java.lang.Object[] args, java.lang.String id)
          Creates a mock for the selected class with the specified id, using the specified args.
protected  java.lang.Object mock(java.lang.Class clazz, java.lang.String id)
          Creates a mock for the selected class with the specified id.
 MultiplicityModifier modify()
           
protected  java.lang.Object monitor(java.lang.Class clazz)
          Use this method to create monitored objects to trace in documentation.
protected  java.lang.Object monitor(java.lang.Class clazz, java.lang.Class[] parameterTypes, java.lang.Object[] arguments, java.lang.String id)
          Use this method to create monitored objects to trace in documentation.
protected  java.lang.Object monitor(java.lang.Class clazz, java.lang.Object[] arguments, java.lang.String id)
          Use this method to create monitored objects to trace in documentation.
protected  java.lang.Object monitor(java.lang.Class clazz, java.lang.String id)
          Use this method to create monitored objects to trace in documentation.
protected  java.lang.Object monitor(java.lang.Object object, java.lang.String id)
          This method is for enabling simpler monitoring setup for e.g.
 void replaceSection(java.lang.String id, Section section)
           
 void setExceptionVerifier(ExceptionVerifier exceptionVerifier)
           
 void setMultiplicityModifier(MultiplicityModifier multiplicityModifier)
           
 void setSectionManager(SectionManager sectionManager)
           
 void startVerification()
          Change state of the mocks to start verify the recorded calls.
protected  java.lang.Object stub(java.lang.Class clazz, java.lang.Class[] signature, java.lang.Object[] arguments, java.lang.String id)
          Deprecated. use intercept instead
protected  java.lang.Object stub(java.lang.Class clazz, java.lang.Object[] arguments, java.lang.String id)
          Deprecated. use intercept instead
protected  java.lang.Object stub(java.lang.Class clazz, java.lang.String id)
          Deprecated. use intercept instead
 
Methods inherited from class com.agical.rmock.extension.junit.AbstractMockStrategyTestCase
createVerifyStep, exceptionVerifierDecorator, getProxyFactory, setProxyFactory, verify
 
Methods inherited from class com.agical.rmock.extension.junit.BasicJUnitStrategyTestCase
createSetupStep, createTearDownStep, createTestStep, setUp, tearDown
 
Methods inherited from class com.agical.rmock.extension.junit.AbstractStrategyTestCase
assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, getHub, getStrategyRunner, getVerifiable, runBare, setAsserter, setStrategyRunner, setTestCaseListener, setVerifiable
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s

protected final SectionFactory s

expect

protected final MultiplicityFactory expect

all

protected final IteratorFactory all

matchAction

protected MatchActionFactory matchAction

doc

protected DocumentationControl doc
Constructor Detail

RMockTestCase

public RMockTestCase()

RMockTestCase

protected RMockTestCase(java.lang.String name)

RMockTestCase

protected RMockTestCase(Hub hub,
                        java.lang.String name)
Method Detail

createStrategy

protected TestStep createStrategy(java.lang.String test)
Description copied from class: AbstractStrategyTestCase
Implement this method to return a strategy to run for the given test.

Overrides:
createStrategy in class AbstractMockStrategyTestCase
Parameters:
test - The test to get the strategy for
Returns:
The strategy for the test.

setMultiplicityModifier

public void setMultiplicityModifier(MultiplicityModifier multiplicityModifier)

mock

protected java.lang.Object mock(java.lang.Class clazz)
Creates a mock for the selected class.
If the clazz represents an object the object MUST be non-final and it MUST have a default constructor. The mocked object is created in the background. The ForwardAction will forward calls to that instance. By default the ReturnsAction will be used (just as for mocked interfaces).

Parameters:
clazz - The interface or object to implement for the mock
Returns:
A new mock implementing the interface passed in the clazz parameter

mock

protected java.lang.Object mock(java.lang.Class clazz,
                                java.lang.String id)
Creates a mock for the selected class with the specified id.
The id MUST be unique within the testmethod
If the clazz represents an object the class MUST be non-final and it MUST have a default constructor. The mocked object is created in the background. The ForwardAction will forward calls to that instance. By default the ReturnsAction will be used (just as for mocked interfaces).

Parameters:
clazz - The interface or object to implement for the mock
id - the name of the recorder
Returns:
A new mock for the object or interface passed in the clazz parameter

mock

protected java.lang.Object mock(java.lang.Class clazz,
                                java.lang.Object[] args,
                                java.lang.String id)
Creates a mock for the selected class with the specified id, using the specified args.
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST have a only one constructor signature assignable from the provided args. The mocked object is created in the background. The ForwardAction will forward calls to that instance. By default the ReturnsAction will be used (just as for mocked interfaces).

Parameters:
clazz - The object to implement for the mock
args - The arguments to the constructor
id - the name of the recorder
Returns:
A new mock for the object passed in the clazz parameter

mock

protected java.lang.Object mock(java.lang.Class clazz,
                                java.lang.Class[] signature,
                                java.lang.Object[] args,
                                java.lang.String id)
Creates a mock for the selected class with the specified id, using the specified args using the constructor with the specified signature. The mocked object is created in the background. The ForwardAction will forward calls to that instance. By default the ReturnsAction will be used (just as for mocked interfaces).
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST of course have a constructor with the provided signature that can accept the provided args.

Parameters:
clazz - The object to implement for the mock
signature - The signature for the constructor to use
args - The arguments to the constructor
id - the name of the recorder
Returns:
A new mock for the object passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.

Parameters:
clazz - The type to implement for the intercepted object
Returns:
A new intercepted object for the type passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz,
                                     java.lang.String id)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.

Parameters:
clazz - The type to implement for the intercepted object
id - the name of the intercepted object
Returns:
A new intercepted object for the type passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz,
                                     java.lang.Class[] signature,
                                     java.lang.Object[] arguments,
                                     java.lang.String id)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST of course have a constructor with the provided signature that can accept the provided args.

Parameters:
clazz - The type to implement for the intercepted object
signature - The signature for the constructor to use
args - The arguments to the constructor
id - the name of the intercepted object
Returns:
A new intercepted object for the type passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz,
                                     java.lang.Class[] signature,
                                     java.lang.Object[] arguments)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.
The class MUST be non-final and it MUST of course have a constructor with the provided signature that can accept the provided args.

Parameters:
clazz - The type to implement for the intercepted object
signature - The signature for the constructor to use
args - The arguments to the constructor
Returns:
A new intercepted object for the type passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz,
                                     java.lang.Object[] arguments,
                                     java.lang.String id)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST have a only one constructor signature assignable from the provided args.

Parameters:
clazz - The type to implement for the intercepted object
args - The arguments to the constructor
id - the name of the intercepted object
Returns:
A new intercepted object for the type passed in the clazz parameter

intercept

protected java.lang.Object intercept(java.lang.Class clazz,
                                     java.lang.Object[] arguments)
intercept creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the intercepted object, those can be made just as with a mock.
The class MUST be non-final and it MUST have a only one constructor signature assignable from the provided args.

Parameters:
clazz - The type to implement for the intercepted object
args - The arguments to the constructor
Returns:
A new intercepted object for the type passed in the clazz parameter

stub

protected java.lang.Object stub(java.lang.Class clazz,
                                java.lang.String id)
Deprecated. use intercept instead

stub creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the stub, those can be made just as with a mock.

Parameters:
clazz - The type to implement for the stub
id - the name of the intercepted object
Returns:
A new intercepted object for the type passed in the clazz parameter

stub

protected java.lang.Object stub(java.lang.Class clazz,
                                java.lang.Class[] signature,
                                java.lang.Object[] arguments,
                                java.lang.String id)
Deprecated. use intercept instead

stub creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the stub, those can be made just as with a mock.
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST of course have a constructor with the provided signature that can accept the provided args.

Parameters:
clazz - The object to implement for the stub
signature - The signature for the constructor to use
args - The arguments to the constructor
id - the name of the stub
Returns:
A new stub for the object passed in the clazz parameter

stub

protected java.lang.Object stub(java.lang.Class clazz,
                                java.lang.Object[] arguments,
                                java.lang.String id)
Deprecated. use intercept instead

stub creates an instance of the specified class (just as mock for a class), but it forwards all calls to that instance. If restrictions should be made on the stub, those can be made just as with a mock.
The id MUST be unique within the testmethod
The class MUST be non-final and it MUST have a only one constructor signature assignable from the provided args.

Parameters:
clazz - The object to implement for the stub
args - The arguments to the constructor
id - the name of the stub
Returns:
A new stub for the object passed in the clazz parameter

fakeAndIntercept

protected java.lang.Object fakeAndIntercept(java.lang.Class itf,
                                            java.lang.String id)
Fake and intercept is meant to be used on interfaces. A fake class that implements the faked interface is dynamically generated and returns default values from all methods. The faked implementation is intercepted by rMock so that expectations can optionally be made on the faked interface.

Parameters:
itf - The interface to fake and intercept
id - The identifier for the resulting proxy
Returns:
A faked and intercepted interface.

fakeAndIntercept

protected java.lang.Object fakeAndIntercept(java.lang.Class itf)
Fake and intercept is meant to be used on interfaces. A fake class that implements the faked interface is dynamically generated and returns default values from all methods. The faked implementation is intercepted by rMock so that expectations can optionally be made on the faked interface.

Parameters:
itf - The interface to fake and intercept
Returns:
A faked and intercepted interface.

startVerification

public void startVerification()
Change state of the mocks to start verify the recorded calls.


monitor

protected java.lang.Object monitor(java.lang.Object object,
                                   java.lang.String id)
This method is for enabling simpler monitoring setup for e.g. an aspectj extension of rMock. For the default version no interceptions are made on objects passed to this method.

Parameters:
object -
id -
Returns:
the object passed in

monitor

protected java.lang.Object monitor(java.lang.Class clazz,
                                   java.lang.String id)
Use this method to create monitored objects to trace in documentation.

At the moment this method just creates the object with the given parameters and returns it.

Parameters:
clazz - The class to create
id - The name of the object for presentation purposes
Returns:
The created object

monitor

protected java.lang.Object monitor(java.lang.Class clazz)
Use this method to create monitored objects to trace in documentation.

At the moment this method just creates the object with the given parameters and returns it.

Parameters:
clazz - The class to create
Returns:
The created object

monitor

protected java.lang.Object monitor(java.lang.Class clazz,
                                   java.lang.Object[] arguments,
                                   java.lang.String id)
Use this method to create monitored objects to trace in documentation.

At the moment this method just creates the object with the given parameters and returns it. From the object array provided it will try to find the most appropriate constructor to use.

Parameters:
clazz - The class to create
arguments - An object array to initialize an instance of class with
id - The name of the object for presentation purposes
Returns:
The created object

monitor

protected java.lang.Object monitor(java.lang.Class clazz,
                                   java.lang.Class[] parameterTypes,
                                   java.lang.Object[] arguments,
                                   java.lang.String id)
Use this method to create monitored objects to trace in documentation.

At the moment this method just creates the object with the given parameters and returns it.

Parameters:
clazz - The class to create
parameterTypes - The signature to create the object with
arguments - The arguments to create the object with
id - The name of the object for presentation purposes
Returns:
The created object

modify

public MultiplicityModifier modify()
Returns:

expectThatExceptionThrown

public void expectThatExceptionThrown(Expression exceptionExpression)
Sets up that an exception is expected to be thrown as a result of this testCase. If an exception is thrown that is matched by this expression it will be caught and the test will pass. If an exception is thrown that is not matched by this expression an UnexpectedException exception will be thrown detailing the expectation and the action exception thrown.

Parameters:
expression - The expression to match the exception type

endSection

protected void endSection()

beginSection

public void beginSection(Section section)

forEach

protected CollectionSelector forEach(Expression expression)

setSectionManager

public void setSectionManager(SectionManager sectionManager)

getExceptionVerifier

protected ExceptionVerifier getExceptionVerifier()

setExceptionVerifier

public void setExceptionVerifier(ExceptionVerifier exceptionVerifier)

replaceSection

public void replaceSection(java.lang.String id,
                           Section section)

appendToSection

public void appendToSection(java.lang.String id)


Copyright © 2005-2009 Agical AB. All Rights Reserved.