Java Doc for StreamableRecordByteArrayInteraction.java in  » Testing » mockrunner-0.4 » com » mockrunner » connector » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.connector 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.mockrunner.connector.StreamableRecordByteArrayInteraction

StreamableRecordByteArrayInteraction
public class StreamableRecordByteArrayInteraction implements InteractionImplementor(Code)
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
public  StreamableRecordByteArrayInteraction()
     Sets the expected request and the response to null, i.e.
public  StreamableRecordByteArrayInteraction(byte[] responseData)
     Sets the expected request to null and prepares the specified response data.
public  StreamableRecordByteArrayInteraction(byte[] expectedRequest, byte[] responseData)
     Sets the specified expected request data and prepares the specified response data.
public  StreamableRecordByteArrayInteraction(byte[] responseData, Class responseClass)
     Sets the expected request to null and prepares the specified response data.
public  StreamableRecordByteArrayInteraction(byte[] expectedRequest, byte[] responseData, Class responseClass)
     Sets the specified expected request data and prepares the specified response data.
public  StreamableRecordByteArrayInteraction(byte[] expectedRequest, Record responseRecord)
     Sets the specified expected request data and the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method.
public  StreamableRecordByteArrayInteraction(Record responseRecord)
     Sets the expected request to null and prepares the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method.

Method Summary
public  booleancanHandle(InteractionSpec interactionSpec, Record actualRequest, Record actualResponse)
     Returns true if this implementor is enabled and will handle the request.
public  voiddisable()
     Disables this implementor.
public  voidenable()
     Enables this implementor.
public  Recordexecute(InteractionSpec interactionSpec, Record actualRequest)
     First version of the execute methods.

This method returns null, if the request does not match according to the contract of StreamableRecordByteArrayInteraction.canHandle .
public  booleanexecute(InteractionSpec interactionSpec, Record actualRequest, Record actualResponse)
     Second version of the execute methods.

This method returns false, if the request does not match according to the contract of StreamableRecordByteArrayInteraction.canHandle .
public  voidsetExpectedRequest(byte[] expectedRequest)
     Sets the specified expected request data.
public  voidsetExpectedRequest(InputStream expectedRequest)
     Reads the expected request data from the specified 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.
public  voidsetResponse(byte[] responseData)
     Prepares the specified response data.
public  voidsetResponse(byte[] responseData, Class responseClass)
     Prepares the specified response data.
public  voidsetResponse(InputStream responseData)
     Reads the response data from the specified InputStream.
public  voidsetResponse(InputStream responseData, Class responseClass)
     Reads the response data from the specified InputStream.
public  voidsetResponse(Record responseRecord)
     Prepares the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method.


Constructor Detail
StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction()(Code)
Sets the expected request and the response to null, i.e. an empty response is returned for every request.



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(byte[] responseData)(Code)
Sets the expected request to null and prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method is set to the default com.mockrunner.mock.connector.cci.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.
Parameters:
  responseData - the response data



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(byte[] expectedRequest, byte[] responseData)(Code)
Sets the specified expected request data and prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method is set to the default com.mockrunner.mock.connector.cci.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.
Parameters:
  expectedRequest - the expected request data
Parameters:
  responseData - the response data



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(byte[] responseData, Class responseClass)(Code)
Sets the expected request to null and prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.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.
Parameters:
  responseData - the response data
Parameters:
  responseClass - the response Record class
throws:
  IllegalArgumentException - if the responseClassis not valid



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(byte[] expectedRequest, byte[] responseData, Class responseClass)(Code)
Sets the specified expected request data and prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.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.
Parameters:
  expectedRequest - the expected request data
Parameters:
  responseData - the response data
Parameters:
  responseClass - the response Record class
throws:
  IllegalArgumentException - if the responseClassis not valid



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(byte[] expectedRequest, Record responseRecord)(Code)
Sets the specified expected request data and the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method. The response Record is ignored for StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record,Record) but takes precedence over the specified response byte data for StreamableRecordByteArrayInteraction.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.
Parameters:
  expectedRequest - the expected request data
Parameters:
  responseRecord - the response Record



StreamableRecordByteArrayInteraction
public StreamableRecordByteArrayInteraction(Record responseRecord)(Code)
Sets the expected request to null and prepares the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method. The response Record is ignored for StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record,Record) but takes precedence over the specified response byte data for StreamableRecordByteArrayInteraction.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.
Parameters:
  responseRecord - the response Record




Method Detail
canHandle
public boolean canHandle(InteractionSpec interactionSpec, Record actualRequest, Record actualResponse)(Code)
Returns true if this implementor is enabled and will handle the request. This method returns true if the following prerequisites are fulfilled:

It is enabled.

The response Record must implement Streamable or it must be null (which is the case, if the actual request targets the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method instead of StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record,Record) ).

The expected request must be 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.

Otherwise, false is returned.
Parameters:
  interactionSpec - the InteractionSpec for the actual call
Parameters:
  actualRequest - the request for the actual call
Parameters:
  actualResponse - the response for the actual call, may be null true if this implementor will handle the request andwill return the specified response, false otherwise



disable
public void disable()(Code)
Disables this implementor. StreamableRecordByteArrayInteraction.canHandle(InteractionSpec,Record,Record) always returns false, if this implementor is disabled.



enable
public void enable()(Code)
Enables this implementor.



execute
public Record execute(InteractionSpec interactionSpec, Record actualRequest) throws ResourceException(Code)
First version of the execute methods.

This method returns null, if the request does not match according to the contract of StreamableRecordByteArrayInteraction.canHandle . This never happens under normal conditions since the InteractionHandler does not call execute, if StreamableRecordByteArrayInteraction.canHandle returns false.

Otherwise, this method returns the specified response. If a response Record object is specified (use StreamableRecordByteArrayInteraction.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 com.mockrunner.mock.connector.cci.MockStreamableByteArrayRecord is created. If no response data is specified at all, an empty com.mockrunner.mock.connector.cci.MockStreamableByteArrayRecord will be returned.
Parameters:
  interactionSpec - the interaction spec
Parameters:
  actualRequest - the actual request the response according to the current request



execute
public boolean execute(InteractionSpec interactionSpec, Record actualRequest, Record actualResponse) throws ResourceException(Code)
Second version of the execute methods.

This method returns false, if the request does not match according to the contract of StreamableRecordByteArrayInteraction.canHandle . This never happens under normal conditions since the InteractionHandler does not call execute, if StreamableRecordByteArrayInteraction.canHandle returns false.

Otherwise, this method fills the response 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 StreamableRecordByteArrayInteraction.canHandle ). If no response data is specified at all, the response Record is not touched but true is returned anyway
Parameters:
  interactionSpec - the interaction spec
Parameters:
  actualRequest - the actual request
Parameters:
  actualResponse - the actual response true under normal conditions



setExpectedRequest
public void setExpectedRequest(byte[] expectedRequest)(Code)
Sets the specified expected request data. The response is returned, if the actual request matches the specified expected request data. It is allowed to pass null for the request data which is equivalent to an empty expected request (i.e. every request is accepted).
Parameters:
  expectedRequest - the expected request data



setExpectedRequest
public void setExpectedRequest(InputStream expectedRequest)(Code)
Reads the expected request data from the specified 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).
Parameters:
  expectedRequest - the expected request



setResponse
public void setResponse(byte[] responseData)(Code)
Prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method is set to the default com.mockrunner.mock.connector.cci.MockStreamableByteArrayRecord . It is allowed to pass null for the response data which is equivalent to an empty response.
Parameters:
  responseData - the response data



setResponse
public void setResponse(byte[] responseData, Class responseClass)(Code)
Prepares the specified response data. The response class for the StreamableRecordByteArrayInteraction.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.
Parameters:
  responseData - the response data
Parameters:
  responseClass - the response Record class
throws:
  IllegalArgumentException - if the responseClassis not valid



setResponse
public void setResponse(InputStream responseData)(Code)
Reads the response data from the specified InputStream. The response class for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method is set to the default com.mockrunner.mock.connector.cci.MockStreamableByteArrayRecord . It is allowed to pass null for the InputStream which is equivalent to an empty response.
Parameters:
  responseData - the response data



setResponse
public void setResponse(InputStream responseData, Class responseClass)(Code)
Reads the response data from the specified InputStream. The response class for the StreamableRecordByteArrayInteraction.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.
Parameters:
  responseData - the response data
Parameters:
  responseClass - the response Record class
throws:
  IllegalArgumentException - if the responseClassis not valid



setResponse
public void setResponse(Record responseRecord)(Code)
Prepares the response Record for the StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record) method. The response Record is ignored for StreamableRecordByteArrayInteraction.execute(InteractionSpec,Record,Record) but takes precedence over the specified response byte data for StreamableRecordByteArrayInteraction.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.
Parameters:
  responseRecord - the response Record



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.