[Httpunit-commit] CVS: httpunit/src/com/meterware/servletunit ServletUnitHttpRequest.java,1.1,1.2 Se
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2000-11-21 22:18:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv18213/src/com/meterware/servletunit Modified Files: ServletUnitHttpRequest.java ServletUnitHttpResponse.java ServletUnitHttpSession.java Log Message: support JSDK 2.2 Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServletUnitHttpRequest.java 2000/11/21 20:44:59 1.1 +++ ServletUnitHttpRequest.java 2000/11/21 22:18:19 1.2 @@ -261,7 +261,7 @@ } -//--------------------------------- Servlet methods ---------------------------------------------------- +//--------------------------------- ServletRequest methods ---------------------------------------------------- /** @@ -469,6 +469,105 @@ } +//--------------------------------- methods added to ServletRequest in JSDK 2.2 ------------------------------------------------ + + + /** + * Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. + **/ + public boolean isSecure() { + throw new RuntimeException( "isSecure not implemented" ); + } + + + /** + * 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. + **/ + public java.util.Locale getLocale() { + throw new RuntimeException( "getLocale not implemented" ); + } + + + /** + * 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. + **/ + public java.util.Enumeration getLocales() { + throw new RuntimeException( "getLocales not implemented" ); + } + + + /** + * Removes an attribute from this request. This method is not generally needed + * as attributes only persist as long as the request is being handled. + **/ + public void removeAttribute( String name ) { + _attributes.remove( name ); + } + + + /** + * 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(java.lang.String) + * is that this method can take a relative path. + **/ + public RequestDispatcher getRequestDispatcher( String path ) { + throw new RuntimeException( "getRequestDispatcher not implemented" ); + } + + + +//--------------------------------- methods added to HttpServletRequest in JSDK 2.2 ------------------------------------------------ + + + /** + * 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. + **/ + public java.security.Principal getUserPrincipal() { + return null; + } + + + /** + * 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. + **/ + public boolean isUserInRole( String role ) { + return false; + } + + + /** + * Returns all the values of the specified request header as an Enumeration of String objects. + **/ + public java.util.Enumeration getHeaders( String name ) { + throw new RuntimeException( "getHeaders not implemented" ); + } + + + /** + * 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 "". + **/ + public java.lang.String getContextPath() { + throw new RuntimeException( "getContextPath not implemented" ); + } + + //--------------------------------------------- package members ---------------------------------------------- Index: ServletUnitHttpResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServletUnitHttpResponse.java 2000/11/21 20:44:59 1.1 +++ ServletUnitHttpResponse.java 2000/11/21 22:18:19 1.2 @@ -24,6 +24,7 @@ import java.util.Enumeration; import java.util.Hashtable; +import java.util.Locale; import java.util.Vector; import javax.servlet.*; @@ -280,6 +281,97 @@ } +//------------------------------- the following methods are new in JSDK 2.2 ---------------------- + + + /** + * Adds a response header with the given name and value. This method allows response headers to have multiple values. + **/ + public void addHeader( String name, String value ) { + throw new RuntimeException( "addHeader not implemented" ); + } + + + /** + * Adds a response header with the given name and value. This method allows response headers to have multiple values. + **/ + public void addIntHeader( String name, int value ) { + throw new RuntimeException( "addIntHeader not implemented" ); + } + + + /** + * Adds a response header with the given name and value. This method allows response headers to have multiple values. + **/ + public void addDateHeader( String name, long value ) { + throw new RuntimeException( "addDateHeader not implemented" ); + } + + + /** + * Sets the preferred buffer size for the body of the response. The servlet container + * will use a buffer at least as large as the size requested. The actual buffer size + * used can be found using getBufferSize. + **/ + public void setBufferSize( int size ) { // XXX throw IllegalStateException if anything has been written + throw new RuntimeException( "setBufferSize not implemented" ); + } + + + /** + * Returns the actual buffer size used for the response. If no buffering is used, this method returns 0. + **/ + public int getBufferSize() { + return 0; + } + + + /** + * Returns a boolean indicating if the response has been committed. A commited response has + * already had its status code and headers written. + **/ + public boolean isCommitted() { + return false; // XXX set true if flushBuffer has been called + } + + + /** + * Forces any content in the buffer to be written to the client. A call to this method automatically + * commits the response, meaning the status code and headers will be written. + **/ + public void flushBuffer() throws IOException { + throw new RuntimeException( "flushBuffer not implemented" ); + } + + + /** + * Clears any data that exists in the buffer as well as the status code and headers. + * If the response has been committed, this method throws an IllegalStateException. + **/ + public void reset() { + throw new RuntimeException( "reset not implemented" ); + } + + + /** + * Sets the locale of the response, setting the headers (including the Content-Type's charset) + * as appropriate. This method should be called before a call to getWriter(). + * By default, the response locale is the default locale for the server. + **/ + public void setLocale( Locale locale ) { + throw new RuntimeException( "setLocale not implemented" ); + } + + + /** + * Returns the locale assigned to the response. + **/ + public Locale getLocale() { + throw new RuntimeException( "getLocale not implemented" ); + } + + + //---------------------------------------- package methods --------------------------------------- Index: ServletUnitHttpSession.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServletUnitHttpSession.java 2000/11/21 20:44:59 1.1 +++ ServletUnitHttpSession.java 2000/11/21 22:18:19 1.2 @@ -24,6 +24,7 @@ import java.net.HttpURLConnection; import java.util.Date; +import java.util.Enumeration; import java.util.Hashtable; import javax.servlet.ServletException; @@ -125,9 +126,42 @@ /** - * Returns the object bound with the specified name in this session or null if no object of that name exists. + * @deprecated as of JSDK 2.2, use getAttribute **/ public Object getValue( String name ) { + return getAttribute( name ); + } + + + /** + * @deprecated as of JSDK 2.2, use setAttribute + **/ + public void putValue( String name, Object value ) { + setAttribute( name, value ); + } + + + /** + * @deprecated as of JSDK 2.2, use removeAttribute + **/ + public void removeValue( String name ) { + removeAttribute( name ); + } + + + /** + * @deprecated as of JSDK 2.2, use getAttributeNames. + **/ + public String[] getValueNames() { + if (_isInvalid) throw new IllegalStateException(); + throw new RuntimeException( "getValueNames not implemented" ); + } + + + /** + * Returns the object bound with the specified name in this session or null if no object of that name exists. + **/ + public Object getAttribute( String name ) { if (_isInvalid) throw new IllegalStateException(); return _values.get( name ); } @@ -137,7 +171,7 @@ * Binds an object to this session, using the name specified. If an object of the same name * is already bound to the session, the object is replaced. **/ - public void putValue( String name, Object value ) { + public void setAttribute( String name, Object value ) { if (_isInvalid) throw new IllegalStateException(); _values.put( name, value ); } @@ -147,7 +181,7 @@ * Removes the object bound with the specified name from this session. If the session does not * have an object bound with the specified name, this method does nothing. **/ - public void removeValue( String name ) { + public void removeAttribute( String name ) { if (_isInvalid) throw new IllegalStateException(); _values.remove( name ); } @@ -157,7 +191,7 @@ * Returns an array containing the names of all the objects bound to this session. * This method is useful, for example, when you want to delete all the objects bound to this session. **/ - public String[] getValueNames() { + public Enumeration getAttributeNames() { if (_isInvalid) throw new IllegalStateException(); throw new RuntimeException( "getValueNames not implemented" ); } |