Groovy Documentation

betamax
[Groovy] Interface Tape


interface Tape

Represents a set of recorded HTTP interactions that can be played back or appended to.


Method Summary
java.lang.String getName()

@return The name of the tape.

boolean isReadable()

@return `true` if the tape is readable, `false` otherwise.

boolean isWritable()

@return `true` if the tape is writable, `false` otherwise.

void play(Response response)

Plays back a previously recorded interaction to the supplied response.

void record(Request request, Response response)

Records a new interaction to the tape.

void reset()

Resets the tape so that no recorded interaction is ready to play.

boolean seek(Request request)

Attempts to find a recorded interaction on the tape that matches the supplied request's method and URI.

void setMode(TapeMode mode)

@param mode the new record mode of the tape.

int size()

@return the number of recorded HTTP interactions currently stored on the tape.

 

Method Detail

getName

java.lang.String getName()
Returns:
The name of the tape.


isReadable

boolean isReadable()
Returns:
`true` if the tape is readable, `false` otherwise.


isWritable

boolean isWritable()
Returns:
`true` if the tape is writable, `false` otherwise.


play

void play(Response response)
Plays back a previously recorded interaction to the supplied response. Status, headers and entities are copied from the recorded interaction to `response`.
throws:
IllegalStateException if no recorded interaction has been found by a previous call to `seek`.
Parameters:
response - the HTTP response to populate.


record

void record(Request request, Response response)
Records a new interaction to the tape. If the tape is currently positioned to read a recorded interaction due to a previous successful `seek` call then this method will overwrite the existing recorded interaction. Otherwise the newly recorded interaction is appended to the tape.
throws:
UnsupportedOperationException if this `Tape` implementation is not writable.
Parameters:
request - the request to record.
response - the response to record.


reset

void reset()
Resets the tape so that no recorded interaction is ready to play. Subsequent calls to `play` will throw `IllegalStateException` until a successful call to `seek` is made.


seek

boolean seek(Request request)
Attempts to find a recorded interaction on the tape that matches the supplied request's method and URI. If the method succeeds then subsequent calls to `play` will play back the response that was found.
Parameters:
request - the HTTP request to match.
Returns:
`true` if a matching recorded interaction was found, `false` otherwise.


setMode

void setMode(TapeMode mode)
Parameters:
mode - the new record mode of the tape.


size

int size()
Returns:
the number of recorded HTTP interactions currently stored on the tape.


 

Groovy Documentation