spock.util.concurrent
@Beta public class PollingConditions extends Object
Usage example:
def conditions = new PollingConditions(timeout: 10, initialDelay: 1.5, factor: 1.25) def machine = new Machine() when: machine.start() then: conditions.eventually { assert machine.temperature >= 100 assert machine.efficiency >= 0.9 }
Constructor and Description |
---|
PollingConditions() |
Modifier and Type | Method and Description |
---|---|
void |
call(Closure<?> conditions)
Alias for
eventually(groovy.lang.Closure) . |
void |
call(double seconds,
Closure<?> conditions)
Alias for
within(double, groovy.lang.Closure) . |
void |
eventually(Closure<?> conditions)
Repeatedly evaluates the specified conditions until they are satisfied or the timeout has elapsed.
|
double |
getDelay()
Returns the delay (in seconds) between successive evaluations of the conditions.
|
double |
getFactor()
Returns the factor by which the delay grows (or shrinks) after each evaluation of the conditions.
|
double |
getInitialDelay()
Returns the initial delay (in seconds) before first evaluating the conditions.
|
double |
getTimeout()
Returns the timeout (in seconds) until which the conditions have to be satisfied.
|
void |
setDelay(double seconds)
Sets the delay (in seconds) between successive evaluations of the conditions.
|
void |
setFactor(double factor)
Sets the factor by which the delay grows (or shrinks) after each evaluation of the conditions.
|
void |
setInitialDelay(double seconds)
Sets the initial delay (in seconds) before first evaluating the conditions.
|
void |
setTimeout(double seconds)
Sets the timeout (in seconds) until which the conditions have to be satisfied.
|
void |
within(double seconds,
Closure<?> conditions)
Repeatedly evaluates the specified conditions until they are satisfied or the specified timeout (in seconds) has elapsed.
|
public double getTimeout()
public void setTimeout(double seconds)
seconds
- the timeout (in seconds) until which the conditions have to be satisfiedpublic double getInitialDelay()
public void setInitialDelay(double seconds)
seconds
- the initial delay (in seconds) before first evaluating the conditionspublic double getDelay()
public void setDelay(double seconds)
seconds
- the delay (in seconds) between successive evaluations of the conditions.public double getFactor()
public void setFactor(double factor)
factor
- the factor by which the delay grows (or shrinks) after each evaluation of the conditionspublic void eventually(Closure<?> conditions) throws InterruptedException
conditions
- the conditions to evaluateInterruptedException
- if evaluation is interruptedpublic void within(double seconds, Closure<?> conditions) throws InterruptedException
conditions
- the conditions to evaluateInterruptedException
- if evaluation is interruptedpublic void call(Closure<?> conditions) throws InterruptedException
eventually(groovy.lang.Closure)
.InterruptedException
public void call(double seconds, Closure<?> conditions) throws InterruptedException
within(double, groovy.lang.Closure)
.InterruptedException