You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/10/26 20:10:47 UTC
cvs commit: jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/util FilterConfiguration.java
vmassol 2002/10/26 11:10:47
Modified: framework/src/java/j2ee13/org/apache/cactus
FilterTestCase.java
framework/src/java/share/org/apache/cactus
ServletTestCase.java JspTestCase.java
AbstractWebTestCase.java WebRequest.java
framework/src/java/share/org/apache/cactus/client/authentication
FormAuthentication.java
documentation/docs/xdocs changes.xml
framework/src/java/share/org/apache/cactus/util
WebConfiguration.java JspConfiguration.java
ServletConfiguration.java
framework/src/java/j2ee13/org/apache/cactus/extension/jetty
JettyInitializer.java
sample-servlet/src/unit/share/org/apache/cactus/unit
TestAbstractWebTestCase.java
framework/src/java/j2ee13/org/apache/cactus/util
FilterConfiguration.java
Added: framework/src/java/share/org/apache/cactus/client
DefaultHttpClient.java
framework/src/java/share/org/apache/cactus/util
AbstractWebConfiguration.java
Removed: framework/src/java/share/org/apache/cactus/client
ServletHttpClient.java JspHttpClient.java
AbstractHttpClient.java
framework/src/java/j2ee13/org/apache/cactus/client
FilterHttpClient.java
Log:
* Fixed bug where the redirector used to fetch Cactus results was always the default redirector even if a test had overriden it using WebRequest.setRedirectorName()
* Fixed bug where the FormAuthentication class was always using the default redirector even if it had been overriden
Revision Changes Path
1.6 +1 -16 jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/FilterTestCase.java
Index: FilterTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/FilterTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FilterTestCase.java 26 Sep 2002 16:43:33 -0000 1.5
+++ FilterTestCase.java 26 Oct 2002 18:10:46 -0000 1.6
@@ -59,11 +59,9 @@
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletResponse;
-import org.apache.cactus.client.FilterHttpClient;
import org.apache.cactus.server.FilterConfigWrapper;
import org.apache.cactus.util.Configuration;
import org.apache.cactus.util.FilterConfiguration;
-import org.apache.cactus.util.WebConfiguration;
/**
* Test classes that need access to valid Filter implicit objects (such as the
@@ -120,19 +118,6 @@
public FilterTestCase(String theName)
{
super(theName);
- }
-
- /**
- * Runs a test case. This method is overriden from the JUnit
- * <code>TestCase</code> class in order to seamlessly call the
- * Cactus redirection servlet.
- *
- * @exception Throwable if the test fails for any reason
- */
- protected void runTest() throws Throwable
- {
- runGenericTest(new FilterHttpClient(
- (WebConfiguration) getConfiguration()));
}
/**
1.5 +1 -18 jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletTestCase.java
Index: ServletTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServletTestCase.java 26 Sep 2002 16:43:32 -0000 1.4
+++ ServletTestCase.java 26 Oct 2002 18:10:47 -0000 1.5
@@ -59,11 +59,9 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.apache.cactus.client.ServletHttpClient;
import org.apache.cactus.server.ServletConfigWrapper;
import org.apache.cactus.util.Configuration;
import org.apache.cactus.util.ServletConfiguration;
-import org.apache.cactus.util.WebConfiguration;
/**
* Test classes that need access to valid Servlet implicit objects (such as the
@@ -120,21 +118,6 @@
public ServletTestCase(String theName)
{
super(theName);
- }
-
- /**
- * Runs a test case. This method is overriden from the JUnit
- * <code>TestCase</code> class in order to seamlessly call the
- * Cactus redirection servlet.
- *
- * @exception Throwable if an error happens during the test case
- * execution. All errors are thrown to the JUnit Test
- * Runner which will report them
- */
- protected void runTest() throws Throwable
- {
- runGenericTest(new ServletHttpClient(
- (WebConfiguration) getConfiguration()));
}
/**
1.4 +1 -17 jakarta-cactus/framework/src/java/share/org/apache/cactus/JspTestCase.java
Index: JspTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/JspTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JspTestCase.java 26 Sep 2002 16:43:32 -0000 1.3
+++ JspTestCase.java 26 Oct 2002 18:10:47 -0000 1.4
@@ -58,11 +58,9 @@
import javax.servlet.jsp.JspWriter;
-import org.apache.cactus.client.JspHttpClient;
import org.apache.cactus.server.PageContextWrapper;
import org.apache.cactus.util.Configuration;
import org.apache.cactus.util.JspConfiguration;
-import org.apache.cactus.util.WebConfiguration;
/**
* Test classes that need access to valid JSP implicit objects (such as the
@@ -101,20 +99,6 @@
public JspTestCase(String theName)
{
super(theName);
- }
-
- /**
- * Runs a test case. This method is overriden from the JUnit
- * <code>TestCase</code> class in order to seamlessly call the
- * Cactus redirection servlet.
- *
- * @exception Throwable if any error happens during the execution of
- * the test
- */
- protected void runTest() throws Throwable
- {
- runGenericTest(new JspHttpClient(
- (WebConfiguration) getConfiguration()));
}
/**
1.11 +19 -4 jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebTestCase.java
Index: AbstractWebTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebTestCase.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AbstractWebTestCase.java 26 Sep 2002 16:43:32 -0000 1.10
+++ AbstractWebTestCase.java 26 Oct 2002 18:10:47 -0000 1.11
@@ -62,7 +62,7 @@
import java.net.HttpURLConnection;
-import org.apache.cactus.client.AbstractHttpClient;
+import org.apache.cactus.client.DefaultHttpClient;
import org.apache.cactus.client.ClientException;
import org.apache.cactus.client.WebResponseObjectFactory;
import org.apache.cactus.util.WebConfiguration;
@@ -246,7 +246,7 @@
* @exception Throwable any error that occurred when calling the test method
* for the current test case.
*/
- protected void runGenericTest(AbstractHttpClient theHttpClient)
+ protected void runGenericTest(DefaultHttpClient theHttpClient)
throws Throwable
{
WebRequest request = new WebRequest(
@@ -283,7 +283,7 @@
* for the current test case.
*/
private HttpURLConnection runWebTest(WebRequest theRequest,
- AbstractHttpClient theHttpClient) throws Throwable
+ DefaultHttpClient theHttpClient) throws Throwable
{
// Add the class name, the method name, the URL to simulate and
// automatic session creation flag to the request
@@ -311,4 +311,19 @@
return connection;
}
+
+ /**
+ * Runs a test case. This method is overriden from the JUnit
+ * <code>TestCase</code> class in order to seamlessly call the
+ * Cactus redirection servlet.
+ *
+ * @exception Throwable if any error happens during the execution of
+ * the test
+ */
+ protected void runTest() throws Throwable
+ {
+ runGenericTest(new DefaultHttpClient(
+ (WebConfiguration) getConfiguration()));
+ }
+
}
1.9 +4 -4 jakarta-cactus/framework/src/java/share/org/apache/cactus/WebRequest.java
Index: WebRequest.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/WebRequest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebRequest.java 26 Sep 2002 21:27:49 -0000 1.8
+++ WebRequest.java 26 Oct 2002 18:10:47 -0000 1.9
@@ -867,7 +867,7 @@
public HttpSessionCookie getSessionCookie()
{
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
- ((WebConfiguration) getConfiguration()).getRedirectorURL(),
+ ((WebConfiguration) getConfiguration()).getRedirectorURL(this),
getConfiguration());
WebRequest request = new WebRequest(getConfiguration());
@@ -883,7 +883,7 @@
catch (Throwable e)
{
throw new ChainedRuntimeException("Failed to connect to ["
- + ((WebConfiguration) getConfiguration()).getRedirectorURL()
+ + ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
@@ -897,7 +897,7 @@
catch (ClientException e)
{
throw new ChainedRuntimeException("Failed to connect to ["
- + ((WebConfiguration) getConfiguration()).getRedirectorURL()
+ + ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
1.6 +8 -5 jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/FormAuthentication.java
Index: FormAuthentication.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/FormAuthentication.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FormAuthentication.java 26 Sep 2002 18:25:24 -0000 1.5
+++ FormAuthentication.java 26 Oct 2002 18:10:47 -0000 1.6
@@ -142,7 +142,7 @@
// Only authenticate the first time this instance is used.
if (this.sessionId == null)
{
- authenticate();
+ authenticate(theRequest);
}
// Sets the session id cookie for the next request.
@@ -198,8 +198,10 @@
}
/**
- * Authenticate the principal by calling the security URL.
*/
- public void authenticate()
+ * Authenticate the principal by calling the security URL.
+ *
+ * @param theRequest the web request used to connect to the Redirector
*/
+ public void authenticate(WebRequest theRequest)
{
//Note: This method needs refactoring. It is too complex.
@@ -207,8 +209,9 @@
{
// Create a helper that will connect to a restricted resource.
- String resource =
- ((WebConfiguration) getConfiguration()).getRedirectorURL();
+ String resource = ((WebConfiguration) getConfiguration())
+ .getRedirectorURL(theRequest);
+
ConnectionHelper helper =
ConnectionHelperFactory.getConnectionHelper(resource,
getConfiguration());
1.1 jakarta-cactus/framework/src/java/share/org/apache/cactus/client/DefaultHttpClient.java
Index: DefaultHttpClient.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.client;
import java.net.HttpURLConnection;
import org.apache.cactus.HttpServiceDefinition;
import org.apache.cactus.ServiceEnumeration;
import org.apache.cactus.WebRequest;
import org.apache.cactus.WebResponse;
import org.apache.cactus.WebTestResult;
import org.apache.cactus.util.ChainedRuntimeException;
import org.apache.cactus.util.IoUtil;
import org.apache.cactus.util.WebConfiguration;
/**
* Performs the steps necessary to run a test. It involves
* opening a first HTTP connection to a server redirector, reading the output
* stream and then opening a second HTTP connection to retrieve the test
* result.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @author <a href="mailto:Jason.Robertson@acs-inc.com">Jason Robertson</a>
*
* @version $Id: AbstractHttpClient.java,v 1.12 2002/09/26 16:43:32 vmassol Exp $
*/
public class DefaultHttpClient
{
/**
* Cactus configuration.
*/
protected WebConfiguration configuration;
/**
* Initialize the Http client.
*
* @param theConfiguration the Cactus configuration
*/
public DefaultHttpClient(WebConfiguration theConfiguration)
{
this.configuration = theConfiguration;
}
/**
* Calls the test method indirectly by calling the Redirector servlet and
* then open a second HTTP connection to retrieve the test results.
*
* @param theRequest the request containing all data to pass to the
* redirector servlet.
*
* @return the <code>HttpURLConnection</code> that contains the HTTP
* response when the test was called.
*
* @exception Throwable if an error occured in the test method or in the
* redirector servlet.
*/
public HttpURLConnection doTest(WebRequest theRequest) throws Throwable
{
// Open the first connection to the redirector to execute the test on
// the server side
HttpURLConnection connection = callRunTest(theRequest);
// Open the second connection to get the test results
WebTestResult result = null;
try
{
result = callGetResult(theRequest);
}
catch (ParsingException e)
{
throw new ChainedRuntimeException("Failed to get the test "
+ "results. This is probably due to an error that happened on "
+ "the server side when trying to execute the tests. Here is "
+ "what was returned by the server : ["
+ new WebResponse(theRequest, connection).getText() + "]", e);
}
// Check if the returned result object returned contains an error or
// not. If yes, we need to raise an exception so that the JUnit
// framework can catch it
if (result.hasException())
{
// Wrap the exception message and stack trace into a fake
// exception class with overloaded <code>printStackTrace()</code>
// methods so that when JUnit calls this method it will print the
// stack trace that was set on the server side.
// If the error was an AssertionFailedError then we use an instance
// of AssertionFailedErrorWrapper (so that JUnit recognize it is
// an AssertionFailedError exception and print it differently in
// it's runner console). Otherwise we use an instance of
// ServletExceptionWrapper.
if (result.getExceptionClassName().equals(
"junit.framework.AssertionFailedError"))
{
throw new AssertionFailedErrorWrapper(
result.getExceptionMessage(),
result.getExceptionClassName(),
result.getExceptionStackTrace());
}
else
{
throw new ServletExceptionWrapper(
result.getExceptionMessage(),
result.getExceptionClassName(),
result.getExceptionStackTrace());
}
}
return connection;
}
/**
* Execute the test by calling the redirector.
*
* @param theRequest the request containing all data to pass to the
* redirector servlet.
* @return the <code>HttpURLConnection</code> that contains the HTTP
* response when the test was called.
*
* @exception Throwable if an error occured in the test method or in the
* redirector servlet.
*/
private HttpURLConnection callRunTest(WebRequest theRequest)
throws Throwable
{
// Specify the service to call on the redirector side
theRequest.addParameter(HttpServiceDefinition.SERVICE_NAME_PARAM,
ServiceEnumeration.CALL_TEST_SERVICE.toString(),
WebRequest.GET_METHOD);
// Open the first connection to the redirector to execute the test on
// the server side
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
this.configuration.getRedirectorURL(theRequest),
this.configuration);
HttpURLConnection connection = helper.connect(theRequest);
// Wrap the connection to ensure that all servlet output is read
// before we ask for results
connection = new AutoReadHttpURLConnection(connection);
// Trigger the transfer of data
connection.getInputStream();
return connection;
}
/**
* Get the test result from the redirector.
*
* @param theOriginalRequest the request that was used to run the test
* @return the result that was returned by the redirector.
*
* @exception Throwable if an error occured in the test method or in the
* redirector servlet.
*/
private WebTestResult callGetResult(WebRequest theOriginalRequest)
throws Throwable
{
WebRequest resultsRequest = new WebRequest(this.configuration);
resultsRequest.addParameter(HttpServiceDefinition.SERVICE_NAME_PARAM,
ServiceEnumeration.GET_RESULTS_SERVICE.toString(),
WebRequest.GET_METHOD);
// Use the same redirector as was used by the original request
resultsRequest.setRedirectorName(
theOriginalRequest.getRedirectorName());
// Add authentication details
if (theOriginalRequest.getAuthentication() != null)
{
resultsRequest.setAuthentication(
theOriginalRequest.getAuthentication());
}
// Open the second connection to get the test results
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
this.configuration.getRedirectorURL(resultsRequest),
this.configuration);
HttpURLConnection resultConnection = helper.connect(resultsRequest);
// Read the test result
WebTestResultParser parser = new WebTestResultParser();
WebTestResult result = parser.parse(
IoUtil.getText(resultConnection.getInputStream()));
return result;
}
}
1.55 +6 -0 jakarta-cactus/documentation/docs/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- changes.xml 17 Oct 2002 18:31:45 -0000 1.54
+++ changes.xml 26 Oct 2002 18:10:47 -0000 1.55
@@ -48,6 +48,12 @@
</devs>
<release version="1.5" date="- in CVS">
+ <action dev="VMA" type="fix" due-to="Pranab Dhar" due-to-email="Pranab.Dhar@dfa.state.ny.us">
+ Fixed bug where a redirector overriden by calling
+ <code>WebRequest.setRedirectorName()</code> was not used to fetch the
+ Cactus test result (the default redirector specified in the Cactus
+ configuration was used instead).
+ </action>
<action dev="VMA" type="fix" due-to="Stephan Merker" due-to-email="Stephan.Merker@cegedim.fr">
Fixed bug where Cactus was using the deprecated HttpClient
<code>PostMethod.setRequestBody(String)</code> which had some bug
1.2 +24 -8 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/WebConfiguration.java
Index: WebConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/WebConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebConfiguration.java 26 Sep 2002 16:43:32 -0000 1.1
+++ WebConfiguration.java 26 Oct 2002 18:10:47 -0000 1.2
@@ -56,6 +56,8 @@
*/
package org.apache.cactus.util;
+import org.apache.cactus.WebRequest;
+
/**
* Extends the generic <code>Configuration<code> interface with methods
* provided configuration information related to Web redirectors.
@@ -67,15 +69,29 @@
public interface WebConfiguration extends Configuration
{
/**
- * @return the redirector URL for the redirector used by the current
- * test case
+ * @return the redirector URL for the default redirector
+ */
+ String getDefaultRedirectorURL();
+
+ /**
+ * @return the default redirector name as defined by the Cactus
+ * configuration
+ */
+ String getDefaultRedirectorName();
+
+ /**
+ * @param theRequest the Web request used to connect to the redirector
+ * @return the redirector URL for the redirector to use. It is either
+ * the default redirector name or the redirector defined in
+ * the Web
*/
- String getRedirectorURL();
+ String getRedirectorURL(WebRequest theRequest);
/**
- * @return the redirector name for the redirector used by the current
- * test case. This is the name under which the redirector is
- * registered.
+ * @param theRequest the Web request used to connect to the redirector
+ * @return the redirector name to use. It is either the default
+ * redirector name or the redirector defined in the Web
+ * Request if it has been overriden
*/
- String getRedirectorName();
-}
\ No newline at end of file
+ String getRedirectorName(WebRequest theRequest);
+}
1.6 +4 -19 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/JspConfiguration.java
Index: JspConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/JspConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JspConfiguration.java 26 Sep 2002 16:43:32 -0000 1.5
+++ JspConfiguration.java 26 Oct 2002 18:10:47 -0000 1.6
@@ -63,11 +63,8 @@
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id$
- *
- * @see Configuration
*/
-public class JspConfiguration extends BaseConfiguration
- implements WebConfiguration
+public class JspConfiguration extends AbstractWebConfiguration
{
/**
* Name of the cactus property that specifies the name of the JSP
@@ -77,21 +74,9 @@
"cactus.jspRedirectorName";
/**
- * Read the JSP redirector name from a System property first and then
- * if it fails from the Cactus configuration file and then use the default
- * "JspRedirector" name if it fails.
- *
- * @return the JSP redirector URL
+ * @see WebConfiguration#getDefaultRedirectorName()
*/
- public String getRedirectorURL()
- {
- return getContextURL() + "/" + getRedirectorName();
- }
-
- /**
- * @return the Servlet redirector name
- */
- public String getRedirectorName()
+ public String getDefaultRedirectorName()
{
String redirectorName =
System.getProperty(CACTUS_JSP_REDIRECTOR_NAME_PROPERTY);
1.7 +5 -18 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/ServletConfiguration.java
Index: ServletConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/ServletConfiguration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletConfiguration.java 26 Sep 2002 16:43:32 -0000 1.6
+++ ServletConfiguration.java 26 Oct 2002 18:10:47 -0000 1.7
@@ -66,8 +66,7 @@
*
* @see Configuration
*/
-public class ServletConfiguration extends BaseConfiguration
- implements WebConfiguration
+public class ServletConfiguration extends AbstractWebConfiguration
{
/**
* Name of the cactus property that specifies the name of the Servlet
@@ -77,21 +76,9 @@
"cactus.servletRedirectorName";
/**
- * Read the Servlet redirector name from a System property first and then
- * if it fails from the Cactus configuration file and then use the default
- * "ServletRedirector" name if it fails.
- *
- * @return the Servlet redirector URL
+ * @see WebConfiguration#getDefaultRedirectorName()
*/
- public String getRedirectorURL()
- {
- return getContextURL() + "/" + getRedirectorName();
- }
-
- /**
- * @return the Servlet redirector name
- */
- public String getRedirectorName()
+ public String getDefaultRedirectorName()
{
String redirectorName =
System.getProperty(CACTUS_SERVLET_REDIRECTOR_NAME_PROPERTY);
@@ -103,5 +90,5 @@
return redirectorName;
}
-
+
}
1.1 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/AbstractWebConfiguration.java
Index: AbstractWebConfiguration.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.util;
import org.apache.cactus.WebRequest;
/**
* Common implementation for all <code>WebConfiguration</code>
* implementations.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: ServletConfiguration.java,v 1.6 2002/09/26 16:43:32 vmassol Exp $
*/
public abstract class AbstractWebConfiguration extends BaseConfiguration
implements WebConfiguration
{
/**
* @see WebConfiguration#getDefaultRedirectorURL()
*/
public String getDefaultRedirectorURL()
{
return getContextURL() + "/" + getDefaultRedirectorName();
}
/**
* @see WebConfiguration#getRedirectorURL()
*/
public String getRedirectorURL(WebRequest theRequest)
{
return getContextURL() + "/" + getRedirectorName(theRequest);
}
/**
* @see WebConfiguration#getRedirectorName()
*/
public String getRedirectorName(WebRequest theRequest)
{
String redirectorName;
if (theRequest.getRedirectorName() != null)
{
redirectorName = theRequest.getRedirectorName();
}
else
{
redirectorName = getDefaultRedirectorName();
}
return redirectorName;
}
}
1.3 +5 -5 jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/extension/jetty/JettyInitializer.java
Index: JettyInitializer.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/extension/jetty/JettyInitializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JettyInitializer.java 26 Sep 2002 16:43:32 -0000 1.2
+++ JettyInitializer.java 26 Oct 2002 18:10:47 -0000 1.3
@@ -213,8 +213,8 @@
theContext.getClass().getMethod("addServlet",
new Class[] { String.class, String.class, String.class })
.invoke(theContext, new Object[] {
- theConfiguration.getRedirectorName(),
- "/" + theConfiguration.getRedirectorName(),
+ theConfiguration.getDefaultRedirectorName(),
+ "/" + theConfiguration.getDefaultRedirectorName(),
ServletTestRedirector.class.getName() });
}
@@ -275,7 +275,7 @@
Object filterHolder = handler.getClass().getMethod("defineFilter",
new Class[] { String.class, String.class })
.invoke(handler, new Object[] {
- theConfiguration.getRedirectorName(),
+ theConfiguration.getDefaultRedirectorName(),
FilterTestRedirector.class.getName() });
filterHolder.getClass().getMethod("applyTo",
@@ -286,8 +286,8 @@
handler.getClass().getMethod("mapPathToFilter",
new Class[] { String.class, String.class })
.invoke(handler, new Object[] {
- "/" + theConfiguration.getRedirectorName(),
- theConfiguration.getRedirectorName() });
+ "/" + theConfiguration.getDefaultRedirectorName(),
+ theConfiguration.getDefaultRedirectorName() });
}
}
1.5 +3 -3 jakarta-cactus/sample-servlet/src/unit/share/org/apache/cactus/unit/TestAbstractWebTestCase.java
Index: TestAbstractWebTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/sample-servlet/src/unit/share/org/apache/cactus/unit/TestAbstractWebTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestAbstractWebTestCase.java 26 Sep 2002 16:43:32 -0000 1.4
+++ TestAbstractWebTestCase.java 26 Oct 2002 18:10:47 -0000 1.5
@@ -56,7 +56,7 @@
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.WebResponse;
-import org.apache.cactus.client.ServletHttpClient;
+import org.apache.cactus.client.DefaultHttpClient;
import org.apache.cactus.util.WebConfiguration;
/**
@@ -109,7 +109,7 @@
*/
protected void runTest() throws Throwable
{
- runGenericTest(new ServletHttpClient(
+ runGenericTest(new DefaultHttpClient(
(WebConfiguration) getConfiguration()));
if (!this.isClientGlobalEndCalled)
1.9 +4 -19 jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/util/FilterConfiguration.java
Index: FilterConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/util/FilterConfiguration.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FilterConfiguration.java 26 Sep 2002 16:43:33 -0000 1.8
+++ FilterConfiguration.java 26 Oct 2002 18:10:47 -0000 1.9
@@ -63,11 +63,8 @@
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id$
- *
- * @see Configuration
*/
-public class FilterConfiguration extends BaseConfiguration
- implements WebConfiguration
+public class FilterConfiguration extends AbstractWebConfiguration
{
/**
* Name of the cactus property that specifies the name of the JSP
@@ -77,21 +74,9 @@
"cactus.filterRedirectorName";
/**
- * Read the Filter redirector name from a System property first and then
- * if it fails from the Cactus configuration file and then use the default
- * "FilterRedirector" name if it fails.
- *
- * @return the Filter redirector URL
+ * @see WebConfiguration#getDefaultRedirectorName()
*/
- public String getRedirectorURL()
- {
- return getContextURL() + "/" + getRedirectorName();
- }
-
- /**
- * @return the Filter redirector name
- */
- public String getRedirectorName()
+ public String getDefaultRedirectorName()
{
String redirectorName =
System.getProperty(CACTUS_FILTER_REDIRECTOR_NAME_PROPERTY);
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>