Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.thoughtworks.selenium.condition
Class DefaultConditionRunner

    java.lang.Object
      com.thoughtworks.selenium.condition.DefaultConditionRunner

All Implemented Interfaces:
  ConditionRunner

Direct Known Subclasses:
  JUnit4AndTestNgConditionRunner, JUnitConditionRunner

    public class DefaultConditionRunner

extends java.lang.Object
implements ConditionRunner

This implementation throws a simple `RuntimeException` when the condition is not met in the `waitFor(Condition)` method. More specific runners are preferred for different testing frameworks. E.g. JUnit tests would prefer to use `JUnitConditionRunner`.

Nested Class Summary
`static class` | `DefaultConditionRunner.Log4jMonitor` A Log4j implementation of `DefaultConditionRunner.Monitor`.
`static interface` | `DefaultConditionRunner.Monitor` A `DefaultConditionRunner.Monitor` can be installed in `DefaultConditionRunner` as an open ended way of being notified of certain events.
`static class` | `DefaultConditionRunner.NoOpMonitor` A no-op implementation of `DefaultConditionRunner.Monitor`.

Nested classes/interfaces inherited from interface com.thoughtworks.selenium.condition.ConditionRunner
`ConditionRunner.Context`

Constructor Summary
`DefaultConditionRunner(DefaultConditionRunner.Monitor monitor, Selenium selenium, int interval, int timeout)`
`DefaultConditionRunner(DefaultConditionRunner.Monitor monitor, Selenium selenium, int initialDelay, int interval, int timeout)`
`DefaultConditionRunner(Selenium selenium)` Constructs an instance of this class with reasonable defaults.
`DefaultConditionRunner(Selenium selenium, int interval, int timeout)` Constructs an instance of this class with a `DefaultConditionRunner.NoOpMonitor`.
`DefaultConditionRunner(Selenium selenium, int initialDelay, int interval, int timeout)` Constructs an instance of this class with a `DefaultConditionRunner.NoOpMonitor`.

Method Summary
`protected void` | `throwAssertionException(java.lang.String message)`
`protected void` | `throwAssertionException(java.lang.String message, java.lang.Throwable throwable)`
`void` | `waitFor(Condition condition)` This method will, every so often, evaluate the given `condition`'s `Condition.isTrue(ConditionRunner.Context)` method, until: it becomes true, in which case it simply returns a certain amount of time is passed, in which case it fails by throwing an failure exception tailored to a given test framework -- e.g.
`void` | `waitFor(java.lang.String narrative, Condition condition)` As above but with an additonal 'should' phrase narrative used in the event of the condition failing to become true

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultConditionRunner

    public DefaultConditionRunner(DefaultConditionRunner.Monitor monitor,
                                  Selenium selenium,
                                  int initialDelay,
                                  int interval,
                                  int timeout)

Parameters:
  `selenium` - the selenium to be passed to the Conditions run from within this runner.
  `initialDelay` - (in millis) how long to wait before the initial test of the condition
  `interval` - (in millis) when waiting for a condition, how long to wait between calls to `Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)`
  `timeout` - (in millis) when waiting for a condition, how long to wait until we give up.

### DefaultConditionRunner

    public DefaultConditionRunner(DefaultConditionRunner.Monitor monitor,
                                  Selenium selenium,
                                  int interval,
                                  int timeout)

Parameters:
  `selenium` - the selenium to be passed to the Conditions run from within this runner.
  `interval` - (in millis) when waiting for a condition, how long to wait between calls to `Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)`
  `timeout` - (in millis) when waiting for a condition, how long to wait until we give up.

### DefaultConditionRunner

    public DefaultConditionRunner(Selenium selenium,
                                  int initialDelay,
                                  int interval,
                                  int timeout)

  Constructs an instance of this class with a `DefaultConditionRunner.NoOpMonitor`.

  See Also:
    `DefaultConditionRunner(Monitor, Selenium, int, int)`

### DefaultConditionRunner

    public DefaultConditionRunner(Selenium selenium,
                                  int interval,
                                  int timeout)

  Constructs an instance of this class with a `DefaultConditionRunner.NoOpMonitor`.

  See Also:
    `DefaultConditionRunner(Monitor, Selenium, int, int)`

### DefaultConditionRunner

    public DefaultConditionRunner(Selenium selenium)

  Constructs an instance of this class with reasonable defaults.

  See Also:
    `DefaultConditionRunner(Monitor, Selenium, int, int)`

Method Detail

### waitFor

    public void waitFor(Condition condition)

  Description copied from interface: `ConditionRunner`
  This method will, every so often, evaluate the given `condition`'s `Condition.isTrue(ConditionRunner.Context)` method, until:

  - it becomes true, in which case it simply returns
  - a certain amount of time is passed, in which case it fails by throwing an failure exception tailored to a given test framework -- e.g. `AssertionFailedError` in the case of JUnit
  - it throws an exception, in which case that is wrapped inside a `RuntimeException` and rethrown

  How often if "every so often" and how long is the "certain amount of time" is left to the specific implementations of this interface.

  Specified by:
    `waitFor` in interface `ConditionRunner`

### waitFor

    public void waitFor(java.lang.String narrative,
                        Condition condition)

  Description copied from interface: `ConditionRunner`
  As above but with an additonal 'should' phrase narrative used in the event of the condition failing to become true

  Specified by:
    `waitFor` in interface `ConditionRunner`

### throwAssertionException

    protected void throwAssertionException(java.lang.String message)

### throwAssertionException

    protected void throwAssertionException(java.lang.String message,
                                           java.lang.Throwable throwable)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. All Rights Reserved.