Package org.netbeans.jemmy
Class Waiter
- java.lang.Object
-
- org.netbeans.jemmy.Waiter
-
- All Implemented Interfaces:
Outputable
,Timeoutable
,Waitable
- Direct Known Subclasses:
WindowWaiter
public class Waiter extends Object implements Waitable, Timeoutable, Outputable
Waits for something defined by Waitable interface to be happened.
Timeouts used:
Waiter.TimeDelta - time delta to check actionProduced result.
Waiter.WaitingTime - maximal waiting time
Waiter.AfterWaitingTime - time to sleep after waiting has been finished.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
actionProduced(Object obj)
Checks if wait criteria have been met.protected String
getActionProducedMessage(long timeSpent, Object result)
Returns message to be printed when waiting has been successfully finished.String
getDescription()
Returns description.protected String
getGoldenActionProducedMessage()
Returns message to be printed int golden output when waiting has been successfully finished.protected String
getGoldenTimeoutExpiredMessage()
Returns message to be printed int golden output when waiting timeout has been expired.protected String
getGoldenWaitingStartedMessage()
Returns message to be printed int golden output before waiting start.TestOut
getOutput()
Returns print output streams or writers.protected String
getTimeoutExpiredMessage(long timeSpent)
Returns message to be printed when waiting timeout has been expired.Timeouts
getTimeouts()
Return current timeouts.protected 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, String useAsWaitingTime)
LikesetTimeouts(Timeouts)
, but clones the timeouts first, then sets "Waiter.WaitingTime" to the timeout whose name is passed in.void
setWaitingTimeOrigin(String origin)
Sets the origin of the current "Waiter.WaitingTime" to be shown in timeout error messagesprotected long
timeFromStart()
Returns time from waiting start.Object
waitAction(Object waitableObject)
Waits for not null result of actionProduced method of Waitable implementation passed into constructor.
-
-
-
Constructor Detail
-
Waiter
public Waiter(Waitable w)
Constructor.- Parameters:
w
- Waitable object defining waiting criteria.
-
Waiter
protected Waiter()
Can be used from subclass.
-
-
Method Detail
-
setTimeouts
public void setTimeouts(Timeouts timeouts)
Defines current timeouts.- Specified by:
setTimeouts
in interfaceTimeoutable
- Parameters:
timeouts
- A collection of timeout assignments.- See Also:
Timeoutable
,Timeouts
,getTimeouts()
-
setTimeoutsToCloneOf
public Timeouts setTimeoutsToCloneOf(Timeouts timeouts, String useAsWaitingTime)
LikesetTimeouts(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.- Parameters:
timeouts
- to be cloned and in which to look up "useAsWaitingTime".useAsWaitingTime
- the name of the timeout to apply to "Waiter.WaitingTime".- Returns:
- the cloned timeouts.
-
setWaitingTimeOrigin
public void setWaitingTimeOrigin(String origin)
Sets the origin of the current "Waiter.WaitingTime" to be shown in timeout error messages- Parameters:
origin
- is the name of the origin.
-
getTimeouts
public Timeouts getTimeouts()
Return current timeouts.- Specified by:
getTimeouts
in interfaceTimeoutable
- Returns:
- the collection of current timeout assignments.
- See Also:
Timeoutable
,Timeouts
,setTimeouts(org.netbeans.jemmy.Timeouts)
-
setOutput
public void setOutput(TestOut out)
Defines print output streams or writers.- Specified by:
setOutput
in interfaceOutputable
- Parameters:
out
- Identify the streams or writers used for print output.- See Also:
Outputable
,TestOut
,getOutput()
-
getOutput
public TestOut getOutput()
Returns print output streams or writers.- Specified by:
getOutput
in interfaceOutputable
- Returns:
- an object that contains references to objects for printing to output and err streams.
- See Also:
Outputable
,TestOut
,setOutput(org.netbeans.jemmy.TestOut)
-
waitAction
public Object waitAction(Object waitableObject) throws InterruptedException
Waits for not null result of actionProduced method of Waitable implementation passed into constructor.- Parameters:
waitableObject
- Object to be passed into actionProduced method.- Returns:
- non null result of action.
- Throws:
TimeoutExpiredException
InterruptedException
-
actionProduced
public Object actionProduced(Object obj)
Description copied from interface:Waitable
Checks if wait criteria have been met.- Specified by:
actionProduced
in interfaceWaitable
- Parameters:
obj
-- Returns:
- null is criteria have not been met.
- See Also:
Waitable
-
getDescription
public String getDescription()
Description copied from interface:Waitable
Returns description.- Specified by:
getDescription
in interfaceWaitable
- Returns:
- a description of the wait criteria.
- See Also:
Waitable
-
getWaitingStartedMessage
protected String getWaitingStartedMessage()
Returns message to be printed before waiting start.- Returns:
- a message.
-
getTimeoutExpiredMessage
protected String getTimeoutExpiredMessage(long timeSpent)
Returns message to be printed when waiting timeout has been expired.- Parameters:
timeSpent
- time from waiting start (milliseconds)- Returns:
- a message.
-
getActionProducedMessage
protected String getActionProducedMessage(long timeSpent, Object result)
Returns message to be printed when waiting has been successfully finished.- Parameters:
timeSpent
- time from waiting start (milliseconds)result
- result of Waitable.actionproduced method.- Returns:
- a message.
-
getGoldenWaitingStartedMessage
protected String getGoldenWaitingStartedMessage()
Returns message to be printed int golden output before waiting start.- Returns:
- a message.
-
getGoldenTimeoutExpiredMessage
protected String getGoldenTimeoutExpiredMessage()
Returns message to be printed int golden output when waiting timeout has been expired.- Returns:
- a message.
-
getGoldenActionProducedMessage
protected String getGoldenActionProducedMessage()
Returns message to be printed int golden output when waiting has been successfully finished.- Returns:
- a message.
-
timeFromStart
protected long timeFromStart()
Returns time from waiting start.- Returns:
- Time spent for waiting already.
-
-