|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Poll
The Poll
annotation can be used for asynchronous HTTP tests that need to poll
the service more than one times.
Please note, that the Poll
annotation only works in combination with the
annotation. This means it can't be used standalone and it
has the same prerequisites as the HttpTest
.HttpTest
By annotating a test method with Poll
you tell the framework to send the request
defined in the HttpTest
more than one times. The amount of requests can be
configured via the times
attribute.
Once a single request has finished on an HTTP test method and the method has a
Poll
annotation attached, a PollState
object will be injected into the
Test object. The PollState
field needs to be annotated with the
annotation and can be used to get a response for a specific
request during a poll series. The last response will be also injected when a
Context
annotated Context
field is available in the
test object. After the injection, the test method will be executed.Response
A simple poll looks like this:
@RunWith( HttpJUnitRunner.class ) public class Example { @Rule public Destination destination = new Destination( "http://localhost" ); @Context private PollState pollState; @Context private Response response; @HttpTest( method = Method.GET, path = "/test" ) @Poll( times = 5, interval = 500 ) public void testMethod() { Response currentResponse = pollState.getResponse( pollState.getTimes() ); com.eclipsesource.restfuse.Assert.assertAccepted( currentResponse ); assertEquals( currentResponse, response ); } }
PollState
,
HttpTest
,
Destination
,
Context
Required Element Summary | |
---|---|
int |
interval
The interval attribute specifies the idle time in milliseconds between two
requests in a poll series. |
int |
times
The times attribute specifies the amount of requests that needs to be send
before JUnit will continue with the next test method. |
Element Detail |
---|
public abstract int interval
The interval
attribute specifies the idle time in milliseconds between two
requests in a poll series.
public abstract int times
The times
attribute specifies the amount of requests that needs to be send
before JUnit will continue with the next test method.
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |