[Httpunit-commit] CVS: httpunit/src/com/meterware/servletunit ServletUnitHttpRequest.java,1.36,1.37
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2006-03-24 19:59:20
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12362/src/com/meterware/servletunit Modified Files: ServletUnitHttpRequest.java ServletUnitHttpResponse.java ServletUnitServletContext.java WebApplication.java Log Message: servletunit upgrades Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- ServletUnitHttpRequest.java 6 Mar 2005 20:18:32 -0000 1.36 +++ ServletUnitHttpRequest.java 24 Mar 2006 19:59:12 -0000 1.37 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2005, Russell Gold +* Copyright (c) 2000-2006, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -486,7 +486,7 @@ } -//--------------------------------- methods added to ServletRequest in JSDK 2.2 ------------------------------------------------ +//--------------------------------- methods added to ServletRequest in Servlet API 2.2 ------------------------------------------------ /** @@ -582,7 +582,7 @@ -//--------------------------------- methods added to HttpServletRequest in JSDK 2.2 ------------------------------------------------ +//--------------------------------- methods added to HttpServletRequest in Servlet API 2.2 ------------------------------------------------ /** @@ -629,7 +629,7 @@ } -//--------------------------------------- methods added to ServletRequest in JSDK 2.3 ---------------------------- +//--------------------------------------- methods added to ServletRequest in Servlet API 2.3 ---------------------------- /** * Returns a java.util.Map of the parameters of this request. @@ -655,7 +655,7 @@ } -//--------------------------------------- methods added to HttpServletRequest in JSDK 2.3 ---------------------------- +//--------------------------------------- methods added to HttpServletRequest in Servlet API 2.3 ---------------------------- /** @@ -683,6 +683,24 @@ } +//--------------------------------------- methods added to ServletRequest in Servlet API 2.4 ---------------------------- + + public int getRemotePort() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getLocalName() { + return "localhost"; + } + + public String getLocalAddr() { + return "127.0.0.1"; + } + + public int getLocalPort() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + //--------------------------------------------- package members ---------------------------------------------- Index: ServletUnitHttpResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- ServletUnitHttpResponse.java 13 Oct 2004 21:57:50 -0000 1.21 +++ ServletUnitHttpResponse.java 24 Mar 2006 19:59:12 -0000 1.22 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004,2006, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -394,7 +394,7 @@ **/ public void reset() { resetBuffer(); - _headers = new Hashtable(); + _headers.clear(); _headersComplete = false; _status = SC_OK; } @@ -448,14 +448,6 @@ //---------------------------------------------- package methods -------------------------------------------------- /** - * Returns the content type defined for this response. - **/ - String getContentType() { - return _contentType; - } - - - /** * Returns the contents of this response. **/ byte[] getContents() { @@ -502,7 +494,7 @@ String getHeaderField( String name ) { if (!_headersComplete) completeHeaders(); - ArrayList values = null; + ArrayList values; synchronized (_headers) { values = (ArrayList) _headers.get( name.toUpperCase() ); } @@ -520,7 +512,7 @@ */ public String[] getHeaderFields(String name) { if (!_headersComplete) completeHeaders(); - ArrayList values = null; + ArrayList values; synchronized (_headers) { values = (ArrayList) _headers.get(name.toUpperCase()); } @@ -531,6 +523,20 @@ } +//--------------------------------------- methods added to ServletRequest in Servlet API 2.4 ---------------------------- + + public void setCharacterEncoding(String string) { + _encoding = string; + } + + /** + * Returns the content type defined for this response. + **/ + public String getContentType() { + return _contentType; + } + + //------------------------------------------- private members ------------------------------------ @@ -548,7 +554,7 @@ private String _statusMessage = "OK"; - private Hashtable _headers = new Hashtable(); + private final Hashtable _headers = new Hashtable(); private boolean _headersComplete; Index: ServletUnitServletContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ServletUnitServletContext.java 3 Mar 2004 01:12:51 -0000 1.14 +++ ServletUnitServletContext.java 24 Mar 2006 19:59:12 -0000 1.15 @@ -63,7 +63,7 @@ /** * Returns the major version of the Java Servlet API that this servlet container supports. - * All implementations that comply with Version 2.3 must have this method return the integer 2. + * All implementations that comply with Version 2.4 must have this method return the integer 2. **/ public int getMajorVersion() { return 2; @@ -72,10 +72,10 @@ /** * Returns the minor version of the Servlet API that this servlet container supports. - * All implementations that comply with Version 2.3 must have this method return the integer 3. + * All implementations that comply with Version 2.4 must have this method return the integer 4. **/ public int getMinorVersion() { - return 3; + return 4; } @@ -345,7 +345,7 @@ * @since HttpUnit 1.3 */ public String getServletContextName() { - return null; + return _application.getDisplayName(); } //------------------------------------------- package members ---------------------------------------------------- Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- WebApplication.java 4 Oct 2004 23:45:35 -0000 1.26 +++ WebApplication.java 24 Mar 2006 19:59:12 -0000 1.27 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2001-2004, Russell Gold + * Copyright (c) 2001-2004, 2006 Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -90,6 +90,8 @@ private ServletUnitServletContext _servletContext; + private String _displayName; + /** * Constructs a default application spec with no information. @@ -122,6 +124,9 @@ if (contextPath != null && contextPath.length() > 0 && !contextPath.startsWith( "/" )) throw new IllegalArgumentException( "Context path " + contextPath + " must start with '/'" ); _contextDir = file; _contextPath = contextPath == null ? "" : contextPath; + NodeList nl = document.getElementsByTagName( "display-name" ); + if (nl.getLength() > 0) _displayName = XMLUtils.getTextValue( nl.item(0) ).trim(); + registerServlets( document ); registerFilters( document ); extractSecurityConstraints( document ); @@ -336,10 +341,11 @@ File getResourceFile( String path ) { + String relativePath = path.startsWith( "/" ) ? path.substring(1) : path; if (_contextDir == null) { - return new File( path.substring(1) ); + return new File( relativePath ); } else { - return new File( _contextDir, path.substring(1) ); + return new File( _contextDir, relativePath ); } } @@ -501,6 +507,9 @@ return urlPattern.equals( urlPath ); } + String getDisplayName() { + return _displayName; + } //============================================= SecurityCheckServlet class ============================================= |