jDummySourceForge.net Logo

net.sf.jdummy
Class JDummyTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jmock.core.VerifyingTestCase
              extended by org.jmock.core.MockObjectSupportTestCase
                  extended by org.jmock.MockObjectTestCase
                      extended by org.jmock.cglib.MockObjectTestCase
                          extended by net.sf.jdummy.JDummyTestCase
All Implemented Interfaces:
Test

public class JDummyTestCase
extends MockObjectTestCase

A base class for tests that use jDummy syntax. This class provides methods for creating mock objects (optionally with dummy value generating default stubs), preconditions and expectations.


Field Summary
protected  DummyValueFactory dummyValueFactory
           
protected  Mockery mockery
           
 
Fields inherited from class org.jmock.core.MockObjectSupportTestCase
ANYTHING, NOT_NULL, NULL
 
Constructor Summary
JDummyTestCase()
           
 
Method Summary
 Mock assertBehavior(java.lang.Object dummy)
          Gets the mock whose proxy()is dummy so that you may add expectations.
 java.util.Collection fillWithDummies(java.util.Collection collection, java.lang.Class type, int count)
          Fills the collection with count new dummies
 java.lang.Object fillWithDummies(java.lang.Object array)
          Fills an array with dummies or random values of a given type.
 java.lang.Object[] fillWithDummies(java.lang.Object[] array)
          Fills an array of object swith dummies values of a given type.
 Generator getGenerator(java.lang.Class type)
           
 java.lang.Object mimic(java.lang.Class type)
          Create a new mock and return its proxy.
 java.lang.Object mimic(java.lang.Class type, java.lang.String name)
           
 java.lang.Object mimicWithDummyValues(java.lang.Class type)
          Returns new dummy with a unique name
 java.lang.Object mimicWithDummyValues(java.lang.Class type, java.lang.String name)
          Creates a new mock object of the given type with the given name and dummy value method results.
 Mock mockForProxy(java.lang.Object dummy)
           
 java.lang.String nextName(java.lang.String baseName)
          Gets the next value of the sequence baseName + "-" + i
 java.lang.Object pickOne(java.lang.Object[] choices)
           
 NameMatchBuilder precondition(java.lang.Object dummy)
          Gets the stubs() mock whose proxy()is dummy.
 Stub returnOneOf(java.util.Collection choices)
           
 Stub returnOneOf(java.lang.Object[] choices)
          A stub that is useful for methods returning enumerations.
 void setGenerator(java.lang.Class type, Generator generator)
           
 void setSeed(long seed)
           
 
Methods inherited from class org.jmock.cglib.MockObjectTestCase
newCoreMock
 
Methods inherited from class org.jmock.MockObjectTestCase
atLeastOnce, defaultMockNameForType, mock, mock, never, once, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, throwException
 
Methods inherited from class org.jmock.core.MockObjectSupportTestCase
and, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, isA, newDummy, newDummy, newDummy, not, or, same, stringContains
 
Methods inherited from class org.jmock.core.VerifyingTestCase
registerToVerify, runBare, unregisterToVerify, verify
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mockery

protected Mockery mockery

dummyValueFactory

protected DummyValueFactory dummyValueFactory
Constructor Detail

JDummyTestCase

public JDummyTestCase()
Method Detail

mimic

public java.lang.Object mimic(java.lang.Class type)
Create a new mock and return its proxy.

Parameters:
type -
Returns:

mimic

public java.lang.Object mimic(java.lang.Class type,
                              java.lang.String name)

mimicWithDummyValues

public java.lang.Object mimicWithDummyValues(java.lang.Class type,
                                             java.lang.String name)
Creates a new mock object of the given type with the given name and dummy value method results.

Parameters:
type -
name -
Returns:

mimicWithDummyValues

public java.lang.Object mimicWithDummyValues(java.lang.Class type)
Returns new dummy with a unique name

Parameters:
type -
Returns:

assertBehavior

public Mock assertBehavior(java.lang.Object dummy)
Gets the mock whose proxy()is dummy so that you may add expectations.

Parameters:
dummy -
Returns:
mockForProxy(dummy)

precondition

public NameMatchBuilder precondition(java.lang.Object dummy)
Gets the stubs() mock whose proxy()is dummy. Intended use is to add behavior, i.e., a stub.

Parameters:
dummy -
Returns:
mockForProxy(dummy).stubs()

returnOneOf

public Stub returnOneOf(java.lang.Object[] choices)
A stub that is useful for methods returning enumerations. Example:
 
   precondition(dummy).method("foo").will(returnOneOf(MyEnum.values))
 

Parameters:
choices - an array
Returns:
a stub that returns a psuedo-random element from the array

pickOne

public java.lang.Object pickOne(java.lang.Object[] choices)

returnOneOf

public Stub returnOneOf(java.util.Collection choices)
Parameters:
choices -
Returns:
returnOneOf(choices.toArray())
See Also:
returnOneOf(Object[])

fillWithDummies

public java.lang.Object fillWithDummies(java.lang.Object array)
Fills an array with dummies or random values of a given type.

Parameters:
array -
Returns:

fillWithDummies

public java.lang.Object[] fillWithDummies(java.lang.Object[] array)
Fills an array of object swith dummies values of a given type.

Parameters:
array -
Returns:

fillWithDummies

public java.util.Collection fillWithDummies(java.util.Collection collection,
                                            java.lang.Class type,
                                            int count)
Fills the collection with count new dummies

Parameters:
collection -
type -
count -
Returns:

getGenerator

public Generator getGenerator(java.lang.Class type)

mockForProxy

public Mock mockForProxy(java.lang.Object dummy)

nextName

public java.lang.String nextName(java.lang.String baseName)
Gets the next value of the sequence baseName + "-" + i

Parameters:
baseName -
Returns:

setGenerator

public void setGenerator(java.lang.Class type,
                         Generator generator)

setSeed

public void setSeed(long seed)

jDummySourceForge.net Logo

Copyright 2005-2005-2006 Mark G. Mendel. All Rights Reserved.