[Httpunit-commit] CVS: httpunit/src/com/meterware/servletunit ServletUnitHttpRequest.java,1.20,1.21
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-02-06 01:33:16
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20202/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java ServletUnitHttpResponse.java
ServletUnitHttpSession.java ServletUnitServletContext.java
Log Message:
ServletUnit bug fixes
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ServletUnitHttpRequest.java 4 Feb 2003 19:17:32 -0000 1.20
+++ ServletUnitHttpRequest.java 6 Feb 2003 01:33:11 -0000 1.21
@@ -239,7 +239,7 @@
if (_session == null && getRequestedSessionId() != null) {
_session = _context.getSession( getRequestedSessionId() );
}
- if (_session == null && create) {
+ if (_session == null ? create : _session.isInvalid()) {
_session = _context.newSession();
}
return _session;
Index: ServletUnitHttpResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ServletUnitHttpResponse.java 4 Nov 2002 21:01:38 -0000 1.15
+++ ServletUnitHttpResponse.java 6 Feb 2003 01:33:11 -0000 1.16
@@ -46,6 +46,7 @@
// rfc1123-date is "Sun, 06 Nov 1994 08:49:37 GMT"
private static final String RFC1123_DATE_SPEC = "EEE, dd MMM yyyy hh:mm:ss z";
+ private boolean _committed;
/**
@@ -377,11 +378,11 @@
/**
- * Returns a boolean indicating if the response has been committed. A commited response has
+ * Returns a boolean indicating if the response has been committed. A committed response has
* already had its status code and headers written.
**/
public boolean isCommitted() {
- return false; // XXX set true if flushBuffer has been called
+ return _committed;
}
@@ -390,7 +391,7 @@
* commits the response, meaning the status code and headers will be written.
**/
public void flushBuffer() throws IOException {
- throw new RuntimeException( "flushBuffer not implemented" );
+ _committed = true;
}
Index: ServletUnitHttpSession.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletUnitHttpSession.java 22 Aug 2002 15:48:41 -0000 1.6
+++ ServletUnitHttpSession.java 6 Feb 2003 01:33:11 -0000 1.7
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2001, Russell Gold
+* Copyright (c) 2000-2003 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
@@ -40,7 +40,7 @@
* between client requests. You can set the maximum time interval with the setMaxInactiveInterval method.
**/
public int getMaxInactiveInterval() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _maxInactiveInterval;
}
@@ -50,7 +50,7 @@
* if no user requests have been made of the session.
**/
public void setMaxInactiveInterval( int interval ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_maxInactiveInterval = interval;
}
@@ -60,7 +60,7 @@
* The identifier is assigned by the servlet engine and is implementation dependent.
**/
public String getId() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _id;
}
@@ -74,7 +74,7 @@
* been invalidated
**/
public long getCreationTime() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _creationTime;
}
@@ -84,7 +84,7 @@
* as the number of milliseconds since midnight January 1, 1970 GMT.
**/
public long getLastAccessedTime() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _lastAccessedTime;
}
@@ -104,7 +104,7 @@
* Invalidates this session and unbinds any objects bound to it.
**/
public void invalidate() {
- _isInvalid = true;
+ _invalid = true;
_values.clear();
}
@@ -145,7 +145,7 @@
* @deprecated as of JSDK 2.2, use getAttributeNames.
**/
public String[] getValueNames() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
throw new RuntimeException( "getValueNames not implemented" );
}
@@ -154,7 +154,7 @@
* 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();
+ if (_invalid) throw new IllegalStateException();
return _values.get( name );
}
@@ -164,7 +164,7 @@
* is already bound to the session, the object is replaced.
**/
public void setAttribute( String name, Object value ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_values.put( name, value );
}
@@ -174,7 +174,7 @@
* have an object bound with the specified name, this method does nothing.
**/
public void removeAttribute( String name ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_values.remove( name );
}
@@ -184,7 +184,7 @@
* This method is useful, for example, when you want to delete all the objects bound to this session.
**/
public Enumeration getAttributeNames() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _values.keys();
}
@@ -246,6 +246,11 @@
}
+ boolean isInvalid() {
+ return _invalid;
+ }
+
+
//------------------------------------- private members ---------------------------------------
private static int _NextID = 1;
@@ -260,7 +265,7 @@
private long _lastAccessedTime = new Date().getTime();
- private boolean _isInvalid;
+ private boolean _invalid;
private Hashtable _values = new Hashtable();
Index: ServletUnitServletContext.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ServletUnitServletContext.java 23 Jun 2002 23:52:39 -0000 1.10
+++ ServletUnitServletContext.java 6 Feb 2003 01:33:11 -0000 1.11
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2002, Russell Gold
+* Copyright (c) 2000-2003, 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
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.FileNotFoundException;
import java.net.URL;
@@ -32,7 +31,6 @@
import java.util.Hashtable;
import java.util.Vector;
import java.util.Set;
-import java.util.Map;
import javax.servlet.*;
@@ -153,7 +151,7 @@
**/
public javax.servlet.RequestDispatcher getRequestDispatcher( String path ) {
try {
- URL url = new URL( "http", "localhost", path );
+ URL url = new URL( "http", "localhost", _application.getContextPath() + path );
return new RequestDispatcherImpl( _application.getServletRequest( url ).getServlet() );
} catch (ServletException e) {
return null;
|