Groovy Documentation

betamax
[Groovy] Class Recorder

java.lang.Object
  betamax.Recorder
All Implemented Interfaces:
org.junit.rules.MethodRule

@Log4j
class Recorder
extends java.lang.Object

This is the main interface to the Betamax proxy. It allows control of Betamax configuration and inserting and ejecting `Tape` instances. The class can also be used as a _JUnit @Rule_ allowing tests annotated with `@Betamax` to run with the Betamax HTTP proxy in the background.


Property Summary
static int DEFAULT_PROXY_PORT

static java.lang.String DEFAULT_TAPE_ROOT

int proxyPort

The port the Betamax proxy will listen on.

java.io.File tapeRoot

The base directory where tape files are stored.

 
Constructor Summary
Recorder()

Recorder(java.util.Properties properties)

 
Method Summary
org.junit.runners.model.Statement apply(org.junit.runners.model.Statement statement, org.junit.runners.model.FrameworkMethod method, java.lang.Object target)

void ejectTape()

'Ejects' the current _tape_, writing its content to file.

Tape getTape()

Gets the current active _tape_.

void insertTape(java.lang.String name, TapeMode mode = READ_WRITE)

Inserts a tape either creating a new one or loading an existing file from `tapeRoot`.

java.lang.Object withTape(java.lang.String name, groovy.lang.Closure closure)

Runs the supplied closure after starting the Betamax proxy and inserting a _tape_.

java.lang.Object withTape(java.lang.String name, java.util.Map arguments, groovy.lang.Closure closure)

Runs the supplied closure after starting the Betamax proxy and inserting a _tape_.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

DEFAULT_PROXY_PORT

static final int DEFAULT_PROXY_PORT


DEFAULT_TAPE_ROOT

static final java.lang.String DEFAULT_TAPE_ROOT


proxyPort

int proxyPort
The port the Betamax proxy will listen on.


tapeRoot

java.io.File tapeRoot
The base directory where tape files are stored.


 
Constructor Detail

Recorder

Recorder()


Recorder

Recorder(java.util.Properties properties)


 
Method Detail

apply

org.junit.runners.model.Statement apply(org.junit.runners.model.Statement statement, org.junit.runners.model.FrameworkMethod method, java.lang.Object target)


ejectTape

void ejectTape()
'Ejects' the current _tape_, writing its content to file. If the proxy is active after calling this method it will no longer record or play back any HTTP traffic until another tape is inserted.


getTape

Tape getTape()
Gets the current active _tape_.
Returns:
the active _tape_.


insertTape

void insertTape(java.lang.String name, TapeMode mode = READ_WRITE)
Inserts a tape either creating a new one or loading an existing file from `tapeRoot`.
Parameters:
name - the name of the _tape_.
mode - the read/write mode of the tape.


withTape

java.lang.Object withTape(java.lang.String name, groovy.lang.Closure closure)
Runs the supplied closure after starting the Betamax proxy and inserting a _tape_. After the closure completes the _tape_ is ejected and the proxy stopped.
Parameters:
name - the name of the _tape_.
closure - the closure to execute.
Returns:
the return value of the closure.


withTape

java.lang.Object withTape(java.lang.String name, java.util.Map arguments, groovy.lang.Closure closure)
Runs the supplied closure after starting the Betamax proxy and inserting a _tape_. After the closure completes the _tape_ is ejected and the proxy stopped.
Parameters:
name - the name of the _tape_.
arguments - arguments that affect the operation of the proxy.
closure - the closure to execute.
Returns:
the return value of the closure.


 

Groovy Documentation