public class Waiter extends java.lang.Object implements Waitable, Timeoutable, Outputable
Modifier and Type | Field and Description |
---|---|
static boolean |
globalTimeoutExpired |
static boolean |
USE_GLOBAL_TIMEOUT
Replace the fine-grained timeouts with a global flag which can be set,
for instance, by a separate thread when a global timeout runs out.
|
Modifier | Constructor and Description |
---|---|
protected |
Waiter()
Can be used from subclass.
|
|
Waiter(Waitable w)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
actionProduced(java.lang.Object obj)
Checks if wait criteria have been met.
|
protected java.lang.String |
getActionProducedMessage(long timeSpent,
java.lang.Object result)
Returns message to be printed when waiting has been successfully finished.
|
java.lang.String |
getDescription()
Returns description.
|
protected java.lang.String |
getGoldenActionProducedMessage()
Returns message to be printed int golden output when waiting has been successfully finished.
|
protected java.lang.String |
getGoldenTimeoutExpiredMessage()
Returns message to be printed int golden output when waiting timeout has been expired.
|
protected java.lang.String |
getGoldenWaitingStartedMessage()
Returns message to be printed int golden output before waiting start.
|
TestOut |
getOutput()
Returns print output streams or writers.
|
protected java.lang.String |
getTimeoutExpiredMessage(long timeSpent)
Returns message to be printed when waiting timeout has been expired.
|
Timeouts |
getTimeouts()
Return current timeouts.
|
protected java.lang.String |
getWaitingStartedMessage()
Returns message to be printed before waiting start.
|
void |
setOutput(TestOut out)
Defines print output streams or writers.
|
void |
setTimeouts(Timeouts timeouts)
Defines current timeouts.
|
Timeouts |
setTimeoutsToCloneOf(Timeouts timeouts,
java.lang.String useAsWaitingTime) |
Timeouts |
setTimeoutsToCloneOf(Timeouts timeouts,
java.lang.String useAsWaitingTime,
java.lang.String waitingTimeOrigin)
Like
setTimeouts(Timeouts) , but clones the timeouts first, then
sets "Waiter.WaitingTime" to the timeout whose name is passed in. |
void |
setWaitingTimeOrigin(java.lang.String origin)
Sets the origin of the current "Waiter.WaitingTime" to be shown in timeout
error messages
|
protected long |
timeFromStart()
Returns time from waiting start.
|
java.lang.Object |
waitAction(java.lang.Object waitableObject)
Waits for not null result of actionProduced method of Waitable implementation passed into constructor.
|
public static volatile boolean USE_GLOBAL_TIMEOUT
public static volatile boolean globalTimeoutExpired
public Waiter(Waitable w)
w
- Waitable object defining waiting criteria.protected Waiter()
public void setTimeouts(Timeouts timeouts)
setTimeouts
in interface Timeoutable
timeouts
- A collection of timeout assignments.Timeoutable
,
Timeouts
,
getTimeouts()
public Timeouts setTimeoutsToCloneOf(Timeouts timeouts, java.lang.String useAsWaitingTime, java.lang.String waitingTimeOrigin)
setTimeouts(Timeouts)
, but clones the timeouts first, then
sets "Waiter.WaitingTime" to the timeout whose name is passed in. This
name is remembered for display in timeout error messages so people know
what to adjust.timeouts
- to be cloned and in which to look up "useAsWaitingTime".useAsWaitingTime
- the name of the timeout to apply to "Waiter.WaitingTime".waitingTimeOrigin
- overrides useAsWaitingTime
in timeout reporting if non-null.public Timeouts setTimeoutsToCloneOf(Timeouts timeouts, java.lang.String useAsWaitingTime)
public void setWaitingTimeOrigin(java.lang.String origin)
origin
- is the name of the origin.public Timeouts getTimeouts()
getTimeouts
in interface Timeoutable
Timeoutable
,
Timeouts
,
setTimeouts(org.netbeans.jemmy.Timeouts)
public void setOutput(TestOut out)
setOutput
in interface Outputable
out
- Identify the streams or writers used for print output.Outputable
,
TestOut
,
getOutput()
public TestOut getOutput()
getOutput
in interface Outputable
Outputable
,
TestOut
,
setOutput(org.netbeans.jemmy.TestOut)
public java.lang.Object waitAction(java.lang.Object waitableObject) throws java.lang.InterruptedException
waitableObject
- Object to be passed into actionProduced method.TimeoutExpiredException
java.lang.InterruptedException
public java.lang.Object actionProduced(java.lang.Object obj)
Waitable
actionProduced
in interface Waitable
obj
- Waitable
public java.lang.String getDescription()
Waitable
getDescription
in interface Waitable
Waitable
protected java.lang.String getWaitingStartedMessage()
protected java.lang.String getTimeoutExpiredMessage(long timeSpent)
timeSpent
- time from waiting start (milliseconds)protected java.lang.String getActionProducedMessage(long timeSpent, java.lang.Object result)
timeSpent
- time from waiting start (milliseconds)result
- result of Waitable.actionproduced method.protected java.lang.String getGoldenWaitingStartedMessage()
protected java.lang.String getGoldenTimeoutExpiredMessage()
protected java.lang.String getGoldenActionProducedMessage()
protected long timeFromStart()