|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjdave.ContainmentSupport
jdave.mock.MockSupport
jdave.Specification<T>
public abstract class Specification<T>
| Field Summary | |
|---|---|
T |
be
|
T |
context
|
protected Specification<T> |
does
|
protected Specification<T> |
must
|
protected Specification<T> |
should
|
| Constructor Summary | |
|---|---|
Specification()
|
|
| Method Summary | ||
|---|---|---|
protected void |
addListener(ILifecycleListener listener)
Add a ILifecycleListener listener to specification. |
|
void |
create()
Create this specification. |
|
void |
destroy()
Destroy this specification. |
|
IEqualityCheck |
equal(long expected)
|
|
IEqualityCheck |
equal(java.lang.Number expectedNumber,
double delta)
|
|
IEqualityCheck |
equal(java.lang.Object obj)
|
|
IEqualityCheck |
equal(java.lang.String obj)
|
|
void |
fireAfterContextCreation(java.lang.Object contextInstance,
java.lang.Object createdContext)
|
|
void |
fireAfterContextDestroy(java.lang.Object contextInstance)
|
|
void |
fireAfterContextInstantiation(java.lang.Object contextInstance)
|
|
IContextObjectFactory<T> |
getContextObjectFactory()
|
|
IEqualityCheck |
isNotNull()
|
|
MapContainment |
maps(java.lang.Object... keys)
|
|
boolean |
needsThreadLocalIsolation()
Returns true if thread local isolation is needed for this specification. |
|
Not<T> |
not()
|
|
|
raise(java.lang.Class<E> expected)
|
|
|
raise(java.lang.Class<E> expectedType,
java.lang.String expectedMessage)
|
|
|
raiseExactly(java.lang.Class<E> expected)
|
|
|
raiseExactly(java.lang.Class<E> expected,
java.lang.String expectedMessage)
|
|
IContract |
satisfies(IContract contract)
|
|
protected void |
setContextObjectFactory(IContextObjectFactory<T> factory)
|
|
static void |
setStringComparisonFailure(IStringComparisonFailure failure)
|
|
|
specify(Block block,
ExpectedException<V> expectation)
The given block is expected to throw an exception. |
|
|
specify(Block block,
ExpectedNoThrow<V> expectation)
The given block is expected to not throw an exception. |
|
void |
specify(boolean expected)
|
|
void |
specify(boolean[] actual,
IContainment containment)
|
|
void |
specify(byte[] actual,
IContainment containment)
|
|
void |
specify(char[] actual,
IContainment containment)
|
|
|
specify(java.util.Collection<E> actual,
IContainment containment)
|
|
|
specify(java.util.Collection<E> actual,
jdave.Where<E> where)
Matches all the actual objects using Hamcrest Matcher. |
|
void |
specify(double[] actual,
IContainment containment)
|
|
void |
specify(float[] actual,
IContainment containment)
|
|
void |
specify(int[] actual,
IContainment containment)
|
|
|
specify(java.lang.Iterable<E> actual,
IContainment containment)
|
|
|
specify(java.lang.Iterable<E> actual,
jdave.Where<E> where)
|
|
|
specify(java.util.Iterator<E> actual,
IContainment containment)
|
|
|
specify(java.util.Iterator<E> actual,
jdave.Where<E> where)
|
|
void |
specify(long[] actual,
IContainment containment)
|
|
void |
specify(java.util.Map<?,?> actual,
MapContainment containment)
|
|
void |
specify(java.lang.Object[] actual,
IContainment containment)
|
|
|
specify(java.lang.Object[] actual,
jdave.Where<E> where)
|
|
void |
specify(java.lang.Object obj,
IContract contract)
|
|
void |
specify(java.lang.Object actual,
IEqualityCheck equalityCheck)
|
|
void |
specify(java.lang.Object actual,
org.hamcrest.Matcher<?> matcher)
Matches the actual object using Hamcrest Matcher. |
|
void |
specify(java.lang.Object actual,
java.lang.Object expected)
|
|
void |
specify(short[] actual,
IContainment containment)
|
|
void |
specify(T actual,
boolean expected)
|
|
void |
specify(T actual,
java.lang.Boolean expected)
|
|
|
where(Each<E> each)
|
|
| Methods inherited from class jdave.mock.MockSupport |
|---|
checking, dummy, dummy, mock, mock, mockery, sequence, setDefaultResultForType, states, verifyMocks |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Specification<T> should
protected Specification<T> does
protected Specification<T> must
public T be
public T context
| Constructor Detail |
|---|
public Specification()
| Method Detail |
|---|
public Not<T> not()
public void specify(boolean expected)
public void specify(T actual,
boolean expected)
public void specify(T actual,
java.lang.Boolean expected)
public <E> void specify(java.lang.Iterable<E> actual,
IContainment containment)
public <E> void specify(java.util.Iterator<E> actual,
IContainment containment)
public <E> void specify(java.util.Collection<E> actual,
IContainment containment)
public void specify(java.lang.Object[] actual,
IContainment containment)
public void specify(boolean[] actual,
IContainment containment)
public void specify(byte[] actual,
IContainment containment)
public void specify(char[] actual,
IContainment containment)
public void specify(double[] actual,
IContainment containment)
public void specify(float[] actual,
IContainment containment)
public void specify(int[] actual,
IContainment containment)
public void specify(long[] actual,
IContainment containment)
public void specify(short[] actual,
IContainment containment)
public void specify(java.lang.Object actual,
java.lang.Object expected)
public void specify(java.lang.Object actual,
IEqualityCheck equalityCheck)
public void specify(java.lang.Object actual,
org.hamcrest.Matcher<?> matcher)
Hamcrest provides a library of matcher objects allowing 'match' rules to be defined declaratively.
import static org.hamcrest.Matchers.*; public class HamcrestSampleSpec extends Specification<Person> { public class SampleContext { public void sample() { specify(person.getAge(), greaterThan(30)); } } }
public <E> void specify(java.util.Collection<E> actual,
jdave.Where<E> where)
Hamcrest provides a library of matcher objects allowing 'match' rules to be defined declaratively.
import static org.hamcrest.Matchers.*; public class HamcrestSampleSpec extends Specification<Person> { public class SampleContext { public void sample() { specify(persons, where(new Each<Person>() {{ matches(item.getAge(), is(greaterThan(30))); }})); } } }
public <E> void specify(java.lang.Iterable<E> actual,
jdave.Where<E> where)
specify(Collection, Where)
public <E> void specify(java.lang.Object[] actual,
jdave.Where<E> where)
specify(Collection, Where)
public <E> void specify(java.util.Iterator<E> actual,
jdave.Where<E> where)
specify(Collection, Where)public <E> jdave.Where<E> where(Each<E> each)
public <V extends java.lang.Throwable> void specify(Block block,
ExpectedException<V> expectation)
There's two variants for setting exception expectations.
The first one accepts the given exception or any of its subclasses, the second one expects an exact exception type. Both can additionally be checked against expected exception message:specify(new Block() { ... }, should.raise(SomeException.class); specify(new Block() { ... }, should.raiseExactly(SomeException.class);
specify(new Block() { ... }, should.raise(SomeException.class, "expected message"); specify(new Block() { ... }, should.raiseExactly(SomeException.class, "expected message");
public <V extends java.lang.Throwable> void specify(Block block,
ExpectedNoThrow<V> expectation)
throws java.lang.Throwable
There's two variants for setting exception expectations.
The first one expects that the given block does not throw the exception or any of its subclasses, the second one expects that the given block does not throw the given exact exception type.specify(new Block() { ... }, should.not().raise(SomeException.class); specify(new Block() { ... }, should.not().raiseExactly(SomeException.class);
java.lang.Throwable
public void specify(java.lang.Object obj,
IContract contract)
public IEqualityCheck equal(long expected)
public IEqualityCheck equal(java.lang.String obj)
public IEqualityCheck equal(java.lang.Object obj)
public IEqualityCheck equal(java.lang.Number expectedNumber,
double delta)
public <E extends java.lang.Throwable> ExpectedException<E> raise(java.lang.Class<E> expected)
specify(Block, ExpectedException),
specify(Block, ExpectedNoThrow)
public <E extends java.lang.Throwable> ExpectedException<E> raise(java.lang.Class<E> expectedType,
java.lang.String expectedMessage)
specify(Block, ExpectedException),
specify(Block, ExpectedNoThrow)public <E extends java.lang.Throwable> ExpectedException<E> raiseExactly(java.lang.Class<E> expected)
specify(Block, ExpectedException),
specify(Block, ExpectedNoThrow)
public <E extends java.lang.Throwable> ExpectedException<E> raiseExactly(java.lang.Class<E> expected,
java.lang.String expectedMessage)
specify(Block, ExpectedException),
specify(Block, ExpectedNoThrow)public IContract satisfies(IContract contract)
public void create()
This method is called before the create method of the executed context has
been called. Override this method to add common initialization code for contexts within
a specification.
public void destroy()
This method is called after the optional destroy method of the excuted context
has been called. Override this method to add common destroy code for contexts within a
specification.
public boolean needsThreadLocalIsolation()
true if thread local isolation is needed for this specification.
Some contexts set thread local variables. This may cause following behaviors to fail if
they depend on initial thread local state. Thread locals can be isolated for all behavior
methods of current specification by overiding this method and returning true.
Then a new fresh thread is created for all methods in the specification.
true if thread local isolation is needed for this specification. The
default is false.protected void setContextObjectFactory(IContextObjectFactory<T> factory)
public IContextObjectFactory<T> getContextObjectFactory()
protected void addListener(ILifecycleListener listener)
ILifecycleListener listener to specification.
ILifecycleListener will be notified when contexts are instantiated and context objects are created and destroyed.
listener - a listener to get lifecycle event notificationspublic void fireAfterContextInstantiation(java.lang.Object contextInstance)
public void fireAfterContextCreation(java.lang.Object contextInstance,
java.lang.Object createdContext)
public void fireAfterContextDestroy(java.lang.Object contextInstance)
public IEqualityCheck isNotNull()
public static void setStringComparisonFailure(IStringComparisonFailure failure)
public MapContainment maps(java.lang.Object... keys)
public void specify(java.util.Map<?,?> actual,
MapContainment containment)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||