|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mockrunner.connector.StreamableRecordByteArrayInteraction
public class StreamableRecordByteArrayInteraction
This interaction implementor works with bytes arrays and streamable
records. It takes a byte array for the request and a byte array or
a Record instance for the response. If the request byte array
is null, which is the default, the implementor accepts any
request and returns the specified result. If a request byte array is specified,
this implementor accepts only requests that are equal to the specified request
byte array. If a request is accepted, this implementor replies with the specified
response. You can use the various constructors and set methods
to configure the expected request data and the response.
Please check out the documentation of the various methods for details.
| Constructor Summary | |
|---|---|
StreamableRecordByteArrayInteraction()
Sets the expected request and the response to null,
i.e. an empty response is returned for every request. |
|
StreamableRecordByteArrayInteraction(byte[] responseData)
Sets the expected request to null and prepares
the specified response data. |
|
StreamableRecordByteArrayInteraction(byte[] expectedRequest,
byte[] responseData)
Sets the specified expected request data and prepares the specified response data. |
|
StreamableRecordByteArrayInteraction(byte[] expectedRequest,
byte[] responseData,
java.lang.Class responseClass)
Sets the specified expected request data and prepares the specified response data. |
|
StreamableRecordByteArrayInteraction(byte[] responseData,
java.lang.Class responseClass)
Sets the expected request to null and prepares
the specified response data. |
|
StreamableRecordByteArrayInteraction(byte[] expectedRequest,
javax.resource.cci.Record responseRecord)
Sets the specified expected request data and the response Record for the execute(InteractionSpec, Record)
method. |
|
StreamableRecordByteArrayInteraction(javax.resource.cci.Record responseRecord)
Sets the expected request to null and prepares the response
Record for the execute(InteractionSpec, Record)
method. |
|
| Method Summary | |
|---|---|
boolean |
canHandle(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest,
javax.resource.cci.Record actualResponse)
Returns true if this implementor is enabled and will handle the request. |
void |
disable()
Disables this implementor. |
void |
enable()
Enables this implementor. |
javax.resource.cci.Record |
execute(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest)
First version of the execute methods. |
boolean |
execute(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest,
javax.resource.cci.Record actualResponse)
Second version of the execute methods. |
void |
setExpectedRequest(byte[] expectedRequest)
Sets the specified expected request data. |
void |
setExpectedRequest(java.io.InputStream expectedRequest)
Reads the expected request data from the specified InputStream. |
void |
setResponse(byte[] responseData)
Prepares the specified response data. |
void |
setResponse(byte[] responseData,
java.lang.Class responseClass)
Prepares the specified response data. |
void |
setResponse(java.io.InputStream responseData)
Reads the response data from the specified InputStream. |
void |
setResponse(java.io.InputStream responseData,
java.lang.Class responseClass)
Reads the response data from the specified InputStream. |
void |
setResponse(javax.resource.cci.Record responseRecord)
Prepares the response Record for the
execute(InteractionSpec, Record) method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StreamableRecordByteArrayInteraction()
null,
i.e. an empty response is returned for every request.
public StreamableRecordByteArrayInteraction(byte[] responseData)
null and prepares
the specified response data. The response class for the
execute(InteractionSpec,Record) method is set
to the default MockStreamableByteArrayRecord.
It is allowed to pass null for the response data which is equivalent
to an empty response.
The specified response is returned for every request.
responseData - the response data
public StreamableRecordByteArrayInteraction(byte[] expectedRequest,
byte[] responseData)
execute(InteractionSpec,Record) method is set
to the default MockStreamableByteArrayRecord.
It is allowed to pass null for the request and response data
which is equivalent to an empty expected request (i.e. every request is accepted)
or to an empty response respectively.
The specified response is returned, if the actual request matches the specified expected
request data.
expectedRequest - the expected request dataresponseData - the response data
public StreamableRecordByteArrayInteraction(byte[] responseData,
java.lang.Class responseClass)
null and prepares
the specified response data. The response class for the
execute(InteractionSpec,Record) method is set
to the specified responseClass. The specified
responseClass must implement Record
and Streamable, otherwise an
IllegalArgumentException will be thrown.
It is allowed to pass null for the response data which is
equivalent to an empty response.
The specified response is returned for every request.
responseData - the response dataresponseClass - the response Record class
java.lang.IllegalArgumentException - if the responseClass
is not valid
public StreamableRecordByteArrayInteraction(byte[] expectedRequest,
byte[] responseData,
java.lang.Class responseClass)
execute(InteractionSpec,Record) method is set
to the specified responseClass. The specified
responseClass must implement Record
and Streamable, otherwise an
IllegalArgumentException will be thrown.
It is allowed to pass null for the request and response data
which is equivalent to an empty expected request (i.e. every request is accepted)
or to an empty response respectively.
The specified response is returned, if the actual request matches the specified expected
request data.
expectedRequest - the expected request dataresponseData - the response dataresponseClass - the response Record class
java.lang.IllegalArgumentException - if the responseClass
is not valid
public StreamableRecordByteArrayInteraction(byte[] expectedRequest,
javax.resource.cci.Record responseRecord)
Record for the execute(InteractionSpec, Record)
method. The response Record is ignored for
execute(InteractionSpec,Record,Record) but takes precedence
over the specified response byte data for execute(InteractionSpec, Record).
It is allowed to pass null for the request and response Record
which is equivalent to an empty expected request (i.e. every request is accepted)
or to no specified response Record, i.e. the specified response
byte data is taken.
The specified response is returned, if the actual request matches the specified expected
request data.
expectedRequest - the expected request dataresponseRecord - the response Recordpublic StreamableRecordByteArrayInteraction(javax.resource.cci.Record responseRecord)
null and prepares the response
Record for the execute(InteractionSpec, Record)
method. The response Record is ignored for
execute(InteractionSpec,Record,Record) but takes precedence
over the specified response byte data for execute(InteractionSpec, Record).
It is allowed to pass null for the response Record
which is equivalent to no specified response Record, i.e. the specified response
byte data is taken.
The specified response is returned for every request.
responseRecord - the response Record| Method Detail |
|---|
public void enable()
public void disable()
canHandle(InteractionSpec, Record, Record)
always returns false, if this implementor is disabled.
public void setExpectedRequest(byte[] expectedRequest)
null for the request data
which is equivalent to an empty expected request (i.e. every request
is accepted).
expectedRequest - the expected request datapublic void setExpectedRequest(java.io.InputStream expectedRequest)
InputStream.
The response is returned, if the actual request matches the expected request data.
It is allowed to pass null for the InputStream
which is equivalent to an empty expected request (i.e. every request
is accepted).
expectedRequest - the expected requestpublic void setResponse(byte[] responseData)
execute(InteractionSpec,Record) method is set
to the default MockStreamableByteArrayRecord.
It is allowed to pass null for the response data
which is equivalent to an empty response.
responseData - the response data
public void setResponse(byte[] responseData,
java.lang.Class responseClass)
execute(InteractionSpec,Record) method is set
to the specified responseClass. The specified
responseClass must implement Record
and Streamable, otherwise an
IllegalArgumentException will be thrown.
It is allowed to pass null for the response data
which is equivalent to an empty response.
responseData - the response dataresponseClass - the response Record class
java.lang.IllegalArgumentException - if the responseClass
is not validpublic void setResponse(java.io.InputStream responseData)
InputStream.
The response class for the execute(InteractionSpec,Record) method
is set to the default
MockStreamableByteArrayRecord.
It is allowed to pass null for the InputStream
which is equivalent to an empty response.
responseData - the response data
public void setResponse(java.io.InputStream responseData,
java.lang.Class responseClass)
InputStream.
The response class for the
execute(InteractionSpec,Record) method is set
to the specified responseClass. The specified
responseClass must implement Record
and Streamable, otherwise an
IllegalArgumentException will be thrown.
It is allowed to pass null for the InputStream
which is equivalent to an empty response.
responseData - the response dataresponseClass - the response Record class
java.lang.IllegalArgumentException - if the responseClass
is not validpublic void setResponse(javax.resource.cci.Record responseRecord)
Record for the
execute(InteractionSpec, Record) method. The response
Record is ignored for execute(InteractionSpec,Record,Record)
but takes precedence over the specified response byte data for
execute(InteractionSpec, Record).
It is allowed to pass null for the response Record
which is equivalent to no specified response Record, i.e. the specified response
byte data is taken.
responseRecord - the response Record
public boolean canHandle(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest,
javax.resource.cci.Record actualResponse)
true if this implementor is enabled and will handle the request.
This method returns true if the following prerequisites are fulfilled:Record must implement Streamable
or it must be null (which is the case, if the actual request
targets the execute(InteractionSpec,Record) method instead of
execute(InteractionSpec,Record,Record)).null (use the various
setExpectedRequest methods) or the actual request Record
must implement Streamable and must contain the same data as
the specified expected request.false is returned.
canHandle in interface InteractionImplementorinteractionSpec - the InteractionSpec for the actual callactualRequest - the request for the actual callactualResponse - the response for the actual call, may be null
true if this implementor will handle the request and
will return the specified response, false otherwise
public javax.resource.cci.Record execute(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest)
throws javax.resource.ResourceException
execute methods.null, if the request does not match
according to the contract of canHandle(javax.resource.cci.InteractionSpec, javax.resource.cci.Record, javax.resource.cci.Record). This never happens under
normal conditions since the InteractionHandler does not call
execute, if canHandle(javax.resource.cci.InteractionSpec, javax.resource.cci.Record, javax.resource.cci.Record) returns false.
Record object is specified (use setResponse(Record)),
it always takes precedence, i.e. the byte array response will be ignored.
If no Record object is specified, a Record object
is created and filled with the specified byte response data. Use the
setResponse methods that take a byte array or an InputStream
to prepare response data. The created Record is of the the
specified type (the setResponse methods that take a second
Class parameter allows for specifying a type). If no type
is specified, a MockStreamableByteArrayRecord
is created. If no response data is specified at all, an empty
MockStreamableByteArrayRecord
will be returned.
execute in interface InteractionImplementorinteractionSpec - the interaction specactualRequest - the actual request
javax.resource.ResourceException
public boolean execute(javax.resource.cci.InteractionSpec interactionSpec,
javax.resource.cci.Record actualRequest,
javax.resource.cci.Record actualResponse)
throws javax.resource.ResourceException
execute methods.false, if the request does not match
according to the contract of canHandle(javax.resource.cci.InteractionSpec, javax.resource.cci.Record, javax.resource.cci.Record). This never happens under
normal conditions since the InteractionHandler does not call
execute, if canHandle(javax.resource.cci.InteractionSpec, javax.resource.cci.Record, javax.resource.cci.Record) returns false.
Record with the
specified byte response data. Use the setResponse methods that
take a byte array or an InputStream to prepare response data.
The response Record must implement Streamable
(it does, otherwise the request would have been rejected by
canHandle(javax.resource.cci.InteractionSpec, javax.resource.cci.Record, javax.resource.cci.Record)). If no response data is specified at all,
the response Record is not touched but true
is returned anyway
execute in interface InteractionImplementorinteractionSpec - the interaction specactualRequest - the actual requestactualResponse - the actual response
true under normal conditions
javax.resource.ResourceException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||