Java Doc for HttpServletRequestSimulator.java in  » Testing » StrutsTestCase » servletunit » 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 » StrutsTestCase » servletunit 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   servletunit.HttpServletRequestSimulator

HttpServletRequestSimulator
public class HttpServletRequestSimulator implements HttpServletRequest(Code)


Field Summary
final public static  intGET
     Constant used by HttpServletRequestSimulator.setMethod to indicate that the GET method made this request.
final public static  intPOST
     Constant used by HttpServletRequestSimulator.setMethod to indicate that the POST method made this request.
final public static  intPUT
     Constant used by HttpServletRequestSimulator.setMethod to indicate that the PUT method made this request.
 StringauthType
    
 StringcharEncoding
    
 StringlocalAddr
    
 StringlocalName
    
 intlocalPort
    
 StringremoteAddr
    
 StringremoteHost
    
 intremotePort
    

Constructor Summary
public  HttpServletRequestSimulator(ServletContext context)
    

Method Summary
public  voidaddCookie(Cookie cookie)
     Adds a cookie that can be retrieved from this request via the getCookies() method.
public  voidaddParameter(String key, String value)
    
public  voidaddParameter(String name, String[] values)
    
public  ObjectgetAttribute(String s)
     Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attributes can be set two ways.

public  EnumerationgetAttributeNames()
     Returns an Enumeration containing the names of the attributes available to this request.
public  StringgetAuthType()
     Returns the name of the authentication scheme used to protect the servlet.
public  StringgetCharacterEncoding()
     Returns the name of the character encoding used in the body of this request.
public  intgetContentLength()
     Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
public  StringgetContentType()
     Returns the MIME type of the body of the request, or null if the type is not known.
public  StringgetContextPath()
     Returns the portion of the request URI that indicates the context of the request.
public  Cookie[]getCookies()
     Returns an array containing all of the Cookie objects the client sent with this request.
public  longgetDateHeader(String name)
     Returns the value of the specified request header as a long value that represents a Date object.
public  StringgetHeader(String s)
     Returns the value of the specified request header as a String.
public  EnumerationgetHeaderNames()
     Returns an enumeration of all the header names this request contains.
public  EnumerationgetHeaders(String s)
     This operation is not supported.
public  ServletInputStreamgetInputStream()
     This operation is not supported.
public  intgetIntHeader(String s)
     Returns the value of the specified request header as an int.
public  StringgetLocalAddr()
    
public  StringgetLocalName()
    
public  intgetLocalPort()
    
public  LocalegetLocale()
     Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
public  EnumerationgetLocales()
     Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
public  StringgetMethod()
     Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
public  StringgetParameter(String s)
     Returns the value of a request parameter as a String, or null if the parameter does not exist.
public  MapgetParameterMap()
     Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request.
public  EnumerationgetParameterNames()
     Returns an Enumeration of String objects containing the names of the parameters contained in this request.
public  String[]getParameterValues(String s)
     Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
public  StringgetPathInfo()
     Returns any extra path information associated with the URL the client sent when it made this request.
public  StringgetPathTranslated()
     This operation is not supported.
public  StringgetProtocol()
     Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
public  StringgetQueryString()
     Returns the query string that is contained in the request URL after the path.
public  BufferedReadergetReader()
     This operation is not supported.
public  StringgetRealPath(String path)
    
public  StringgetRemoteAddr()
     Returns the Internet Protocol (IP) address of the client that sent the request.
public  StringgetRemoteHost()
     Returns the fully qualified name of the client that sent the request.
public  intgetRemotePort()
    
public  StringgetRemoteUser()
     Returns the fully qualified name of the client that sent the request.
public  RequestDispatchergetRequestDispatcher(String url)
     Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.

The pathname specified may be relative, although it cannot extend outside the current servlet context.

public  StringgetRequestURI()
     Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
public  StringBuffergetRequestURL()
     Reconstructs the URL the client used to make the request.
public  StringgetRequestedSessionId()
     Returns the session ID specified by the client.
public  StringgetScheme()
     Returns the name of the scheme used to make this request, for example, http, https, or ftp.
public  StringgetServerName()
     Returns the host name of the server that received the request.
public  intgetServerPort()
     Returns the port number on which this request was received.
public  StringgetServletPath()
     Returns the part of this request's URL that calls the servlet.
public  HttpSessiongetSession()
     Returns the current session associated with this request, or if the request does not have a session, creates one.
public  HttpSessiongetSession(boolean b)
     Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.

If create is false and the request has no valid HttpSession, this method returns null.

To make sure the session is properly maintained, you must call this method before the response is committed.

public  PrincipalgetUserPrincipal()
     Returns a java.security.Principal object containing the name of the current authenticated user.
public  booleanisRequestedSessionIdFromCookie()
     Checks whether the requested session ID came in as a cookie.
public  booleanisRequestedSessionIdFromURL()
     Checks whether the requested session ID came in as part of the request URL.
public  booleanisRequestedSessionIdFromUrl()
    
public  booleanisRequestedSessionIdValid()
     Checks whether the requested session ID is still valid.
public  booleanisSecure()
     Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
public  booleanisUserInRole(String s)
     Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
public  voidremoveAttribute(String s)
     Removes an attribute from this request.
public  voidsetAttribute(String name, Object o)
     Stores an attribute in this request. Attributes are reset between requests.
public  voidsetAuthType(String s)
     Sets authentication scheme to be used in HttpServletRequestSimulator.getAuthType .
public  voidsetCharacterEncoding(String s)
     Sets character encoding to be used in HttpServletRequestSimulator.getCharacterEncoding .
public  voidsetContentType(String s)
     Sets content type to be used in HttpServletRequestSimulator.getContentType .
public  voidsetContextPath(String s)
     Sets the context path to be used by HttpServletRequestSimulator.getContextPath .
public  voidsetCookies(Cookie[] cookies)
     Adds a set of cookies that can be retrieved from this request via the getCookies() method.
public  voidsetDateHeader(String name, long millis)
     Sets a header with the appropriate date string given the time in milliseconds.
public  voidsetHeader(String key, String value)
     Sets a header to be used in HttpServletRequestSimulator.getHeader .
public  voidsetLocalAddr(String localAddr)
    
public  voidsetLocalName(String localName)
    
public  voidsetLocalPort(int localPort)
    
public  voidsetLocale(Locale locale)
     Sets the locale to be used by HttpServletRequestSimulator.getLocale .
public  voidsetMethod(int methodType)
     Sets the name of the HTTP method with which this request was made.
public  voidsetParameterValue(String key, String[] value)
     Sets parameter value to be used by HttpServletRequestSimulator.getParameter .
public  voidsetPathInfo(String s)
     Sets path information to be used by HttpServletRequestSimulator.getPathInfo .
public  voidsetQueryString(String s)
     Sets query string to be used by HttpServletRequestSimulator.getQueryString .
public  voidsetRemoteAddr(String remoteAddr)
     Sets remote address to be used by HttpServletRequestSimulator.getRemoteAddr .
public  voidsetRemoteHost(String remoteHost)
     Sets remote host to be used by HttpServletRequestSimulator.getRemoteHost .
public  voidsetRemotePort(int remotePort)
    
public  voidsetRemoteUser(String remoteUser)
     Sets remote user to be used by HttpServletRequestSimulator.getRemoteUser .
public  voidsetRequestURI(String requestURI)
     Sets request URI to be used by HttpServletRequestSimulator.getRequestURI .
public  voidsetRequestURL(String url)
     Sets the request URL to be used in this test.
public  voidsetRequestedSessionId(String s)
     Sets requested session ID to be used by HttpServletRequestSimulator.getRequestedSessionId .
public  voidsetScheme(String s)
     Sets scheme to be used by HttpServletRequestSimulator.getScheme .
public  voidsetServerName(String s)
     Sets server name to be used by HttpServletRequestSimulator.getServerName .
public  voidsetServerPort(int port)
     Sets the server port to be used with HttpServletRequestSimulator.getServerPort .
public  voidsetServletPath(String s)
     Sets servlet path to be used by HttpServletRequestSimulator.getServletPath .
public  voidsetUserPrincipal(Principal principal)
     Sets the Principal used by HttpServletRequestSimulator.getUserPrincipal .
public  voidsetUserRole(String role)
    

Field Detail
GET
final public static int GET(Code)
Constant used by HttpServletRequestSimulator.setMethod to indicate that the GET method made this request.



POST
final public static int POST(Code)
Constant used by HttpServletRequestSimulator.setMethod to indicate that the POST method made this request.



PUT
final public static int PUT(Code)
Constant used by HttpServletRequestSimulator.setMethod to indicate that the PUT method made this request.



authType
String authType(Code)



charEncoding
String charEncoding(Code)



localAddr
String localAddr(Code)



localName
String localName(Code)



localPort
int localPort(Code)



remoteAddr
String remoteAddr(Code)



remoteHost
String remoteHost(Code)



remotePort
int remotePort(Code)




Constructor Detail
HttpServletRequestSimulator
public HttpServletRequestSimulator(ServletContext context)(Code)




Method Detail
addCookie
public void addCookie(Cookie cookie)(Code)
Adds a cookie that can be retrieved from this request via the getCookies() method.
Parameters:
  cookie - a Cookie object to be retrieved from thisrequest.
See Also:   HttpServletRequestSimulator.getCookies



addParameter
public void addParameter(String key, String value)(Code)
Adds a parameter to this object's list of parameters
Parameters:
  key - The name of the parameter
Parameters:
  value - The value of the parameter



addParameter
public void addParameter(String name, String[] values)(Code)
Adds a parameter as a String array to this object's list of parameters



getAttribute
public Object getAttribute(String s)(Code)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using ServletRequest.setAttribute . This allows information to be embedded into a request before a RequestDispatcher call.

Attribute names should follow the same conventions as package names. This specification reserves names matching java.*, javax.*, and sun.*.
Parameters:
  s - a String specifying the name ofthe attribute an Object containing the valueof the attribute, or null ifthe attribute does not exist




getAttributeNames
public Enumeration getAttributeNames()(Code)
Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it. an Enumeration of stringscontaining the namesof the request's attributes



getAuthType
public String getAuthType()(Code)
Returns the name of the authentication scheme used to protect the servlet. All servlet containers support basic, form and client certificate authentication, and may additionally support digest authentication. If the servlet is not authenticated null is returned.

Same as the value of the CGI variable AUTH_TYPE. one of the static members BASIC_AUTH,FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH(suitable for == comparison)indicating the authentication scheme, ornull if the request wasnot authenticated.




getCharacterEncoding
public String getCharacterEncoding()(Code)
Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding a String containing the name ofthe chararacter encoding, or nullif the request does not specify a character encoding



getContentLength
public int getContentLength()(Code)
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH. -1, since this is a mock container



getContentType
public String getContentType()(Code)
Returns the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE. a String containing the nameof the MIME type ofthe request, or null if the type is not known



getContextPath
public String getContextPath()(Code)
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string. a String specifying theportion of the request URI that indicates the contextof the request



getCookies
public Cookie[] getCookies()(Code)
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent. an array of all the Cookiesincluded with this request, or nullif the request has no cookies



getDateHeader
public long getDateHeader(String name)(Code)
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.

If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.
Parameters:
  name - a String specifying the name of the header a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the reqest.



getHeader
public String getHeader(String s)(Code)
Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. You can use this method with any request header.
Parameters:
  s - a String specifying theheader name a String containing thevalue of the requestedheader, or nullif the request does nothave a header of that name



getHeaderNames
public Enumeration getHeaderNames()(Code)
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.

Some servlet containers do not allow do not allow servlets to access headers using this method, in which case this method returns null an enumeration of all theheader names sent with thisrequest; if the request hasno headers, an empty enumeration;if the servlet container does notallow servlets to use this method,null




getHeaders
public Enumeration getHeaders(String s)(Code)
This operation is not supported.



getInputStream
public ServletInputStream getInputStream() throws IOException(Code)
This operation is not supported.



getIntHeader
public int getIntHeader(String s)(Code)
Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException.

The header name is case insensitive.
Parameters:
  s - a String specifying the nameof a request header an integer expressing the valueof the request header or -1if the request doesn't have aheader of this name
exception:
  NumberFormatException - If the header valuecan't be convertedto an int




getLocalAddr
public String getLocalAddr()(Code)



getLocalName
public String getLocalName()(Code)



getLocalPort
public int getLocalPort()(Code)



getLocale
public Locale getLocale()(Code)
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server. the preferred Locale for the client,defaults to Locale.US if HttpServletRequestSimulator.setLocale hasnot been called.



getLocales
public Enumeration getLocales()(Code)
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server. an Enumeration of preferred Locale objects for the client



getMethod
public String getMethod()(Code)
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD. a Stringspecifying the nameof the method with whichthis request was made



getParameter
public String getParameter(String s)(Code)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use HttpServletRequestSimulator.getParameterValues .

If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via HttpServletRequestSimulator.getInputStream or HttpServletRequestSimulator.getReader can interfere with the execution of this method.
Parameters:
  s - a String specifying thename of the parameter a String representing thesingle value of the parameter
See Also:   HttpServletRequestSimulator.getParameterValues




getParameterMap
public Map getParameterMap()(Code)
Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data. an immutable java.util.Map containing parameter names askeys and parameter values as map values. The keys in the parametermap are of type String. The values in the parameter map are of typeString array.



getParameterNames
public Enumeration getParameterNames()(Code)
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration. an Enumeration of Stringobjects, each String containingthe name of a request parameter; or anempty Enumeration if therequest has no parameters



getParameterValues
public String[] getParameterValues(String s)(Code)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

If the parameter has a single value, the array has a length of 1.
Parameters:
  s - a String containing the name ofthe parameter whose value is requested an array of String objectscontaining the parameter's values
See Also:   HttpServletRequestSimulator.getParameter




getPathInfo
public String getPathInfo()(Code)
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.

Same as the value of the CGI variable PATH_INFO. a String, decoded by theweb container, specifyingextra path information that comesafter the servlet path but beforethe query string in the request URL;or null if the URL does not haveany extra path information




getPathTranslated
public String getPathTranslated()(Code)
This operation is not supported.



getProtocol
public String getProtocol()(Code)
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL. a String containing the protocolname and version number



getQueryString
public String getQueryString()(Code)
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING. a String containing the querystring or null if the URLcontains no query string. The value is notdecoded by the container.



getReader
public BufferedReader getReader() throws IOException(Code)
This operation is not supported.



getRealPath
public String getRealPath(String path)(Code)
ServletContext.getRealPath



getRemoteAddr
public String getRemoteAddr()(Code)
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR. a String containing theIP address of the client that sent the request



getRemoteHost
public String getRemoteHost()(Code)
Returns the fully qualified name of the client that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST. a String containing the fullyqualified name of the client



getRemotePort
public int getRemotePort()(Code)



getRemoteUser
public String getRemoteUser()(Code)
Returns the fully qualified name of the client that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST. a String containing the fullyqualified name of the client



getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String url)(Code)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.

The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. This method returns null if the servlet container cannot return a RequestDispatcher.

The difference between this method and ServletContext.getRequestDispatcher is that this method can take a relative path.
Parameters:
  url - a String specifying the pathnameto the resource a RequestDispatcher objectthat acts as a wrapper for the resourceat the specified path
See Also:   RequestDispatcherSimulator
See Also:   ServletContextSimulator.getRequestDispatcher




getRequestURI
public String getRequestURI()(Code)
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example:
First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1/some/path.html
GET http://foo.bar/a.html HTTP/1.0 /a.html
HEAD /xyz?a=b HTTP/1.1/xyz
a String containingthe part of the URL from theprotocol name up to the query string



getRequestURL
public StringBuffer getRequestURL()(Code)
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters.

This method is useful for creating redirect messages and for reporting errors. a StringBuffer object containing the reconstructed URL



getRequestedSessionId
public String getRequestedSessionId()(Code)
Returns the session ID specified by the client. This may not be the same as the ID of the actual session in use. For example, if the request specified an old (expired) session ID and the server has started a new session, this method gets a new session with a new ID. If the request did not specify a session ID, this method returns null. a String specifying the sessionID, or null if the request didnot specify a session ID
See Also:   HttpServletRequestSimulator.isRequestedSessionIdValid



getScheme
public String getScheme()(Code)
Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738. a String containing the nameof the scheme used to make this request



getServerName
public String getServerName()(Code)
Returns the host name of the server that received the request. For HTTP servlets, same as the value of the CGI variable SERVER_NAME. the name of the server to which the request was sent



getServerPort
public int getServerPort()(Code)
Returns the port number on which this request was received. For HTTP servlets, same as the value of the CGI variable SERVER_PORT. an integer specifying the port number



getServletPath
public String getServletPath()(Code)
Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME. a String containingthe name or path of the servlet beingcalled, as specified in the request URL,decoded.



getSession
public HttpSession getSession()(Code)
Returns the current session associated with this request, or if the request does not have a session, creates one. the HttpSession associatedwith this request
See Also:   HttpServletRequestSimulator.getSession(boolean)



getSession
public HttpSession getSession(boolean b)(Code)
Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.

If create is false and the request has no valid HttpSession, this method returns null.

To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
Parameters:
  b - true to createa new session for this request if necessary;false to return nullif there's no current session the HttpSession associatedwith this request or null ifcreate is falseand the request has no valid session
See Also:   HttpServletRequestSimulator.getSession()




getUserPrincipal
public Principal getUserPrincipal()(Code)
Returns a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null. a java.security.Principal containingthe name of the user making this request;null if the user has not beenauthenticated



isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()(Code)
Checks whether the requested session ID came in as a cookie. true in all cases
See Also:   HttpServletRequestSimulator.getSession



isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()(Code)
Checks whether the requested session ID came in as part of the request URL. false in all cases.
See Also:   HttpServletRequestSimulator.getSession



isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()(Code)
HttpServletRequestSimulator.isRequestedSessionIdFromURL



isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()(Code)
Checks whether the requested session ID is still valid. true if thisrequest has an id for a valid sessionin the current session context;false otherwise
See Also:   HttpServletRequestSimulator.getRequestedSessionId
See Also:   HttpServletRequestSimulator.getSession



isSecure
public boolean isSecure()(Code)
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. true if scheme has been set to HTTPS (ignoring case)



isUserInRole
public boolean isUserInRole(String s)(Code)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.
Parameters:
  s - a String specifying the nameof the role false in all cases



removeAttribute
public void removeAttribute(String s)(Code)
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.

Attribute names should follow the same conventions as package names. Names beginning with java.*, javax.*, and com.sun.*, are reserved for use by Sun Microsystems.
Parameters:
  s - a String specifyingthe name of the attribute to remove




setAttribute
public void setAttribute(String name, Object o)(Code)
Stores an attribute in this request. Attributes are reset between requests. This method is most often used in conjunction with RequestDispatcher .

Attribute names should follow the same conventions as package names. Names beginning with java.*, javax.*, and com.sun.*, are reserved for use by Sun Microsystems.
If the value passed in is null, the effect is the same as calling HttpServletRequestSimulator.removeAttribute .
Parameters:
  name - a String specifyingthe name of the attribute
Parameters:
  o - the Object to be stored




setAuthType
public void setAuthType(String s)(Code)
Sets authentication scheme to be used in HttpServletRequestSimulator.getAuthType .



setCharacterEncoding
public void setCharacterEncoding(String s)(Code)
Sets character encoding to be used in HttpServletRequestSimulator.getCharacterEncoding .



setContentType
public void setContentType(String s)(Code)
Sets content type to be used in HttpServletRequestSimulator.getContentType .



setContextPath
public void setContextPath(String s)(Code)
Sets the context path to be used by HttpServletRequestSimulator.getContextPath .



setCookies
public void setCookies(Cookie[] cookies)(Code)
Adds a set of cookies that can be retrieved from this request via the getCookies() method.
Parameters:
  cookies - an array of Cookie object to be retrieved from thisrequest.
See Also:   HttpServletRequestSimulator.getCookies



setDateHeader
public void setDateHeader(String name, long millis)(Code)
Sets a header with the appropriate date string given the time in milliseconds.
Parameters:
  name - the name of the header
Parameters:
  millis - the time in milliseconds



setHeader
public void setHeader(String key, String value)(Code)
Sets a header to be used in HttpServletRequestSimulator.getHeader .



setLocalAddr
public void setLocalAddr(String localAddr)(Code)



setLocalName
public void setLocalName(String localName)(Code)



setLocalPort
public void setLocalPort(int localPort)(Code)



setLocale
public void setLocale(Locale locale)(Code)
Sets the locale to be used by HttpServletRequestSimulator.getLocale .



setMethod
public void setMethod(int methodType)(Code)
Sets the name of the HTTP method with which this request was made. This value will be returned in the getMethod method.
Parameters:
  methodType - one of the following constant valuesdefined in this class: HttpServletRequestSimulator.GET, HttpServletRequestSimulator.POST, and HttpServletRequestSimulator.PUT



setParameterValue
public void setParameterValue(String key, String[] value)(Code)
Sets parameter value to be used by HttpServletRequestSimulator.getParameter .



setPathInfo
public void setPathInfo(String s)(Code)
Sets path information to be used by HttpServletRequestSimulator.getPathInfo .



setQueryString
public void setQueryString(String s)(Code)
Sets query string to be used by HttpServletRequestSimulator.getQueryString .



setRemoteAddr
public void setRemoteAddr(String remoteAddr)(Code)
Sets remote address to be used by HttpServletRequestSimulator.getRemoteAddr .



setRemoteHost
public void setRemoteHost(String remoteHost)(Code)
Sets remote host to be used by HttpServletRequestSimulator.getRemoteHost .



setRemotePort
public void setRemotePort(int remotePort)(Code)



setRemoteUser
public void setRemoteUser(String remoteUser)(Code)
Sets remote user to be used by HttpServletRequestSimulator.getRemoteUser .



setRequestURI
public void setRequestURI(String requestURI)(Code)
Sets request URI to be used by HttpServletRequestSimulator.getRequestURI .



setRequestURL
public void setRequestURL(String url)(Code)
Sets the request URL to be used in this test. This method uses the given request URL to also set the scheme, server name, server port, request URI, and query string.



setRequestedSessionId
public void setRequestedSessionId(String s)(Code)
Sets requested session ID to be used by HttpServletRequestSimulator.getRequestedSessionId .



setScheme
public void setScheme(String s)(Code)
Sets scheme to be used by HttpServletRequestSimulator.getScheme .



setServerName
public void setServerName(String s)(Code)
Sets server name to be used by HttpServletRequestSimulator.getServerName .



setServerPort
public void setServerPort(int port)(Code)
Sets the server port to be used with HttpServletRequestSimulator.getServerPort .



setServletPath
public void setServletPath(String s)(Code)
Sets servlet path to be used by HttpServletRequestSimulator.getServletPath .



setUserPrincipal
public void setUserPrincipal(Principal principal)(Code)
Sets the Principal used by HttpServletRequestSimulator.getUserPrincipal .



setUserRole
public void setUserRole(String role)(Code)
Sets user role to be used in HttpServletRequestSimulator.isUserInRole



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.