vmassol 2002/09/26 09:43:33
Modified: framework/src/java/share/org/apache/cactus/util
Configuration.java JspConfiguration.java
ServletConfiguration.java
framework/src/java/share/org/apache/cactus
ServletTestCase.java JspTestCase.java
AbstractTestCase.java AbstractWebTestCase.java
WebRequest.java
framework/src/java/share/org/apache/cactus/client/authentication
AbstractAuthentication.java FormAuthentication.java
framework/src/java/share/org/apache/cactus/client
ServletHttpClient.java JspHttpClient.java
ClientInitializer.java ConnectionHelperFactory.java
AbstractHttpClient.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/share/org/apache/cactus/server/runner
ServletTestRunner.java
framework/src/java/j2ee13/org/apache/cactus/util
FilterConfiguration.java
framework/src/test/share/org/apache/cactus
TestAbstractTestCaseInterceptorTestCase.java
TestWebRequest.java
framework/src/java/j2ee13/org/apache/cactus
FilterTestCase.java
framework/src/java/j2ee13/org/apache/cactus/client
FilterHttpClient.java
Added: framework/src/java/share/org/apache/cactus/util
BaseConfiguration.java WebConfiguration.java
Log:
* Big refactoring (hope I haven't broken anything): cleaned up the Cactus
Configuration classes
* Fixed the FormAuthentication class so that it works with any web redirector (and
not only with ServletTestCase)
Revision Changes Path
1.14 +7 -170
jakarta-cactus/framework/src/java/share/org/apache/cactus/util/Configuration.java
Index: Configuration.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/Configuration.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Configuration.java 1 Sep 2002 17:02:37 -0000 1.13
+++ Configuration.java 26 Sep 2002 16:43:32 -0000 1.14
@@ -56,193 +56,30 @@
*/
package org.apache.cactus.util;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import java.util.Enumeration;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-import org.apache.cactus.client.HttpClientConnectionHelper;
-
/**
- * Provides access to the Cactus configuration parameters that are independent
- * of any redirector. All Cactus configuration are defined as Java System
- * Properties. However, a Cactus configuration can also be used, in which case
- * all properties defined withint it will be exported as Java System Properties.
- *
+ * Contains all configuration information for the Cactus framework.
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
* @version $Id$
*/
-public class Configuration
+public interface Configuration
{
/**
- * Name of the Cactus configuration file if cactus is to look for it in
- * the classpath.
- */
- private static final String DEFAULT_CONFIG_NAME = "cactus";
-
- /**
- * Name of the java property for specifying the location of the cactus
- * configuration file. This overrides any cactus configuration file that is
- * put in the classpath.
- */
- private static final String CACTUS_CONFIG_PROPERTY = "cactus.config";
-
- /**
- * Name of Cactus property that specify the URL up to the webapp context.
- * This is the base URL to call for the redirectors. It is made up of :
- * "http://" + serverName + port + "/" + contextName.
- */
- public static final String CACTUS_CONTEXT_URL_PROPERTY =
- "cactus.contextURL";
-
- /**
- * Name of the Cactus property for overriding the default
- * {@link org.apache.cactus.client.ConnectionHelper}. Defaults to
- * {@link org.apache.cactus.client.HttpClientConnectionHelper}
- */
- private static final String CACTUS_CONNECTION_HELPER_CLASSNAME_PROPERTY =
- "cactus.connectionHelper.classname";
-
- /**
- * Default {@link org.apache.cactus.client.ConnectionHelper} to use.
- */
- public static final String DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME =
- HttpClientConnectionHelper.class.getName();
-
- /**
- * Name of the Cactus property for defining an initializer (i.e. a class
- * that is executed before the Cactus tests start on the client side).
- */
- private static final String CACTUS_INITIALIZER_PROPERTY =
- "cactus.initializer";
-
- /**
- * True if the Cactus configuration file has already been read.
- * @see #initialize()
- */
- private static boolean isInitialized;
-
- /**
- * Read the cactus configuration file from the java property defined
- * on the command line (named CACTUS_CONFIG_PROPERTY) and if none has been
- * defined tries to read the DEFAULT_CONFIG_NAME file from the classpath.
- * All properties found are exported as java system properties.
- */
- public static final void initialize()
- {
- if (!isInitialized)
- {
- ResourceBundle config;
-
- // Has the user passed the location of the cactus configuration
- // file as a java property
- String configOverride = System.getProperty(CACTUS_CONFIG_PROPERTY);
-
- if (configOverride == null)
- {
- // Try to read the default cactus configuration file from the
- // classpath
- try
- {
- config = ClassLoaderUtils.loadPropertyResourceBundle(
- DEFAULT_CONFIG_NAME, Configuration.class);
- }
- catch (MissingResourceException e)
- {
- // Cannot find cactus properties file. Do nothing.
- return;
- }
- }
- else
- {
- // Try to read from specified properties file
- try
- {
- config = new PropertyResourceBundle(
- new FileInputStream(configOverride));
- }
- catch (IOException e)
- {
- throw new ChainedRuntimeException(
- "Cannot read cactus configuration file ["
- + configOverride + "]", e);
- }
- }
-
- Enumeration keys = config.getKeys();
-
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
-
- // Only set the system property if it does not already exist.
- // This allows to have a cactus properties file and override
- // some values on the command line.
- if (System.getProperty(key) == null)
- {
- System.setProperty(key, config.getString(key));
- }
- }
-
- isInitialized = true;
- }
- }
-
- /**
* @return the context URL under which our application to test runs.
*/
- public static String getContextURL()
- {
- initialize();
-
- // Try to read it from a System property first and then if it fails
- // from the Cactus configuration file.
- String contextURL = System.getProperty(CACTUS_CONTEXT_URL_PROPERTY);
-
- if (contextURL == null)
- {
- throw new ChainedRuntimeException("Missing Cactus property ["
- + CACTUS_CONTEXT_URL_PROPERTY + "]");
- }
-
- return contextURL;
- }
+ String getContextURL();
/**
* @return the {@link org.apache.cactus.client.ConnectionHelper} classname
* to use for opening the HTTP connection
*/
- public static String getConnectionHelper()
- {
- initialize();
-
- // Try to read it from a System property first and then if not defined
- // use the default.
- String connectionHelperClassname =
- System.getProperty(CACTUS_CONNECTION_HELPER_CLASSNAME_PROPERTY);
-
- if (connectionHelperClassname == null)
- {
- connectionHelperClassname =
- DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME;
- }
-
- return connectionHelperClassname;
- }
+ String getConnectionHelper();
/**
* @return the initializer class (i.e. a class that is executed before the
* Cactus tests start on the client side) or null if none has been
* defined
*/
- public static String getInitializer()
- {
- initialize();
-
- return System.getProperty(CACTUS_INITIALIZER_PROPERTY);
- }
+ String getInitializer();
}
1.5 +16 -10
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JspConfiguration.java 30 Aug 2002 20:08:31 -0000 1.4
+++ JspConfiguration.java 26 Sep 2002 16:43:32 -0000 1.5
@@ -66,7 +66,8 @@
*
* @see Configuration
*/
-public class JspConfiguration extends Configuration
+public class JspConfiguration extends BaseConfiguration
+ implements WebConfiguration
{
/**
* Name of the cactus property that specifies the name of the JSP
@@ -82,20 +83,25 @@
*
* @return the JSP redirector URL
*/
- public static String getJspRedirectorURL()
+ public String getRedirectorURL()
{
- initialize();
+ return getContextURL() + "/" + getRedirectorName();
+ }
- // Try to read it from a System property first and then if it fails
- // from the Cactus configuration file.
- String jspRedirectorName =
+ /**
+ * @return the Servlet redirector name
+ */
+ public String getRedirectorName()
+ {
+ String redirectorName =
System.getProperty(CACTUS_JSP_REDIRECTOR_NAME_PROPERTY);
- if (jspRedirectorName == null)
+ if (redirectorName == null)
{
- jspRedirectorName = "JspRedirector";
+ redirectorName = "JspRedirector";
}
- return getContextURL() + "/" + jspRedirectorName;
+ return redirectorName;
}
+
}
1.6 +10 -13
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServletConfiguration.java 1 Sep 2002 17:03:23 -0000 1.5
+++ ServletConfiguration.java 26 Sep 2002 16:43:32 -0000 1.6
@@ -66,7 +66,8 @@
*
* @see Configuration
*/
-public class ServletConfiguration extends Configuration
+public class ServletConfiguration extends BaseConfiguration
+ implements WebConfiguration
{
/**
* Name of the cactus property that specifies the name of the Servlet
@@ -82,29 +83,25 @@
*
* @return the Servlet redirector URL
*/
- public static String getServletRedirectorURL()
+ public String getRedirectorURL()
{
- initialize();
-
- return getContextURL() + "/" + getServletRedirectorName();
+ return getContextURL() + "/" + getRedirectorName();
}
/**
* @return the Servlet redirector name
*/
- public static String getServletRedirectorName()
+ public String getRedirectorName()
{
- initialize();
-
- String servletRedirectorName =
+ String redirectorName =
System.getProperty(CACTUS_SERVLET_REDIRECTOR_NAME_PROPERTY);
- if (servletRedirectorName == null)
+ if (redirectorName == null)
{
- servletRedirectorName = "ServletRedirector";
+ redirectorName = "ServletRedirector";
}
- return servletRedirectorName;
+ return redirectorName;
}
}
1.1
jakarta-cactus/framework/src/java/share/org/apache/cactus/util/BaseConfiguration.java
Index: BaseConfiguration.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 [EMAIL PROTECTED]
*
* 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 java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import org.apache.cactus.client.HttpClientConnectionHelper;
/**
* Provides access to the Cactus configuration parameters that are independent
* of any redirector. All Cactus configuration are defined as Java System
* Properties. However, a Cactus configuration can also be used, in which case
* all properties defined withint it will be exported as Java System Properties.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
* @version $Id: Configuration.java,v 1.13 2002/09/01 17:02:37 vmassol Exp $
*/
public class BaseConfiguration implements Configuration
{
/**
* Name of the Cactus configuration file if cactus is to look for it in
* the classpath.
*/
private static final String DEFAULT_CONFIG_NAME = "cactus";
/**
* Name of the java property for specifying the location of the cactus
* configuration file. This overrides any cactus configuration file that is
* put in the classpath.
*/
private static final String CACTUS_CONFIG_PROPERTY = "cactus.config";
/**
* Name of Cactus property that specify the URL up to the webapp context.
* This is the base URL to call for the redirectors. It is made up of :
* "http://" + serverName + port + "/" + contextName.
*/
public static final String CACTUS_CONTEXT_URL_PROPERTY =
"cactus.contextURL";
/**
* Name of the Cactus property for overriding the default
* {@link org.apache.cactus.client.ConnectionHelper}. Defaults to
* {@link org.apache.cactus.client.HttpClientConnectionHelper}
*/
private static final String CACTUS_CONNECTION_HELPER_CLASSNAME_PROPERTY =
"cactus.connectionHelper.classname";
/**
* Default {@link org.apache.cactus.client.ConnectionHelper} to use.
*/
public static final String DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME =
HttpClientConnectionHelper.class.getName();
/**
* Name of the Cactus property for defining an initializer (i.e. a class
* that is executed before the Cactus tests start on the client side).
*/
private static final String CACTUS_INITIALIZER_PROPERTY =
"cactus.initializer";
/**
* Initialize all Cactus configuration properties.
*/
public BaseConfiguration()
{
initialize();
}
/**
* Read the cactus configuration file from the java property defined
* on the command line (named CACTUS_CONFIG_PROPERTY) and if none has been
* defined tries to read the DEFAULT_CONFIG_NAME file from the classpath.
* All properties found are exported as java system properties.
*/
private void initialize()
{
ResourceBundle config;
// Has the user passed the location of the cactus configuration
// file as a java property
String configOverride = System.getProperty(CACTUS_CONFIG_PROPERTY);
if (configOverride == null)
{
// Try to read the default cactus configuration file from the
// classpath
try
{
config = ClassLoaderUtils.loadPropertyResourceBundle(
DEFAULT_CONFIG_NAME, BaseConfiguration.class);
}
catch (MissingResourceException e)
{
// Cannot find cactus properties file. Do nothing.
return;
}
}
else
{
// Try to read from specified properties file
try
{
config = new PropertyResourceBundle(
new FileInputStream(configOverride));
}
catch (IOException e)
{
throw new ChainedRuntimeException(
"Cannot read cactus configuration file ["
+ configOverride + "]", e);
}
}
Enumeration keys = config.getKeys();
while (keys.hasMoreElements())
{
String key = (String) keys.nextElement();
// Only set the system property if it does not already exist.
// This allows to have a cactus properties file and override
// some values on the command line.
if (System.getProperty(key) == null)
{
System.setProperty(key, config.getString(key));
}
}
}
/**
* @return the context URL under which our application to test runs.
*/
public String getContextURL()
{
initialize();
// Try to read it from a System property first and then if it fails
// from the Cactus configuration file.
String contextURL = System.getProperty(CACTUS_CONTEXT_URL_PROPERTY);
if (contextURL == null)
{
throw new ChainedRuntimeException("Missing Cactus property ["
+ CACTUS_CONTEXT_URL_PROPERTY + "]");
}
return contextURL;
}
/**
* @return the {@link org.apache.cactus.client.ConnectionHelper} classname
* to use for opening the HTTP connection
*/
public String getConnectionHelper()
{
initialize();
// Try to read it from a System property first and then if not defined
// use the default.
String connectionHelperClassname =
System.getProperty(CACTUS_CONNECTION_HELPER_CLASSNAME_PROPERTY);
if (connectionHelperClassname == null)
{
connectionHelperClassname =
DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME;
}
return connectionHelperClassname;
}
/**
* @return the initializer class (i.e. a class that is executed before the
* Cactus tests start on the client side) or null if none has been
* defined
*/
public String getInitializer()
{
initialize();
return System.getProperty(CACTUS_INITIALIZER_PROPERTY);
}
}
1.1
jakarta-cactus/framework/src/java/share/org/apache/cactus/util/WebConfiguration.java
Index: WebConfiguration.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 [EMAIL PROTECTED]
*
* 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;
/**
* Extends the generic <code>Configuration<code> interface with methods
* provided configuration information related to Web redirectors.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
* @version $Id: $
*/
public interface WebConfiguration extends Configuration
{
/**
* @return the redirector URL for the redirector used by the current
* test case
*/
String getRedirectorURL();
/**
* @return the redirector name for the redirector used by the current
* test case. This is the name under which the redirector is
* registered.
*/
String getRedirectorName();
}
1.4 +15 -2
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServletTestCase.java 29 Aug 2002 19:56:03 -0000 1.3
+++ ServletTestCase.java 26 Sep 2002 16:43:32 -0000 1.4
@@ -61,6 +61,9 @@
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
@@ -130,6 +133,16 @@
*/
protected void runTest() throws Throwable
{
- runGenericTest(new ServletHttpClient());
+ runGenericTest(new ServletHttpClient(
+ (WebConfiguration) getConfiguration()));
}
+
+ /**
+ * @see AbstractTestCase#createConfiguration()
+ */
+ protected Configuration createConfiguration()
+ {
+ return new ServletConfiguration();
+ }
+
}
1.3 +15 -2
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JspTestCase.java 29 Aug 2002 19:56:19 -0000 1.2
+++ JspTestCase.java 26 Sep 2002 16:43:32 -0000 1.3
@@ -60,6 +60,9 @@
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
@@ -110,6 +113,16 @@
*/
protected void runTest() throws Throwable
{
- runGenericTest(new JspHttpClient());
+ runGenericTest(new JspHttpClient(
+ (WebConfiguration) getConfiguration()));
}
+
+ /**
+ * @see AbstractTestCase#createConfiguration()
+ */
+ protected Configuration createConfiguration()
+ {
+ return new JspConfiguration();
+ }
+
}
1.15 +52 -4
jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractTestCase.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AbstractTestCase.java 11 Sep 2002 19:11:12 -0000 1.14
+++ AbstractTestCase.java 26 Sep 2002 16:43:32 -0000 1.15
@@ -63,6 +63,7 @@
import junit.framework.TestCase;
import org.apache.cactus.client.ClientInitializer;
+import org.apache.cactus.util.Configuration;
import org.apache.cactus.util.JUnitVersionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -121,6 +122,12 @@
public static final String LOG_CLIENT_CONFIG = "log_client.properties";
/**
+ * Flag used to verify if client initialization has already been performed
+ * for the current test suite or not.
+ */
+ private static boolean isClientInitialized;
+
+ /**
* The name of the current test method being executed. This name is valid
* both on the client side and on the server side, meaning you can call it
* from a <code>testXXX()</code>, <code>setUp()</code> or
@@ -135,6 +142,11 @@
private Log logger;
/**
+ * The Cactus configuration.
+ */
+ private Configuration configuration;
+
+ /**
* Constructs a JUnit test case with the given name.
*
* @param theName the name of the test case
@@ -155,6 +167,21 @@
}
/**
+ * @return the Cactus configuration
*/
+ protected Configuration getConfiguration()
+ {
+ return this.configuration;
+ }
+
+ /**
+ * Sets the Cactus configuration.
+ *
* @param theConfiguration the Cactus configuration
*/
+ protected void setConfiguration(Configuration theConfiguration)
+ {
+ this.configuration = theConfiguration;
+ }
+
+ /**
* @return the name of the test method to call without the
* TEST_METHOD_PREFIX prefix
*/
@@ -210,9 +237,11 @@
// actual class name (that's why the logged instance is not static).
this.logger = LogFactory.getLog(this.getClass());
- // Call client side initializer (if defined). It will be called only
- // once.
- ClientInitializer.initialize();
+ // Initialize client side configuration
+ if (!isClientInitialized)
+ {
+ initializeClientSide();
+ }
// Mark beginning of test on client side
getLogger().debug("------------- Test: " + this.getCurrentTestMethod());
@@ -229,6 +258,25 @@
}
}
+ /**
+ * Perform client side initialization that need to be performed once
+ * per test suite.
+ */
+ protected void initializeClientSide()
+ {
+ // Call abstract method that initialize Cactus configuration
+ setConfiguration(createConfiguration());
+
+ // Call client side initializer (if defined). It will be called only
+ // once per test suite
+ ClientInitializer.initialize(getConfiguration());
+ }
+
+ /**
+ * Creates the Cactus configuration object.
+ *
* @return the Cactus configuration
*/
+ protected abstract Configuration createConfiguration();
+
/**
* Runs a test case. This method is overriden from the JUnit
* <code>TestCase</code> class in order to seamlessly call the
1.10 +4 -2
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractWebTestCase.java 30 Aug 2002 20:09:30 -0000 1.9
+++ AbstractWebTestCase.java 26 Sep 2002 16:43:32 -0000 1.10
@@ -65,6 +65,7 @@
import org.apache.cactus.client.AbstractHttpClient;
import org.apache.cactus.client.ClientException;
import org.apache.cactus.client.WebResponseObjectFactory;
+import org.apache.cactus.util.WebConfiguration;
/**
* Abstract class for Web Test Cases (i.e. HTTP connection to the server) that
@@ -248,7 +249,8 @@
protected void runGenericTest(AbstractHttpClient theHttpClient)
throws Throwable
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(
+ (WebConfiguration) getConfiguration());
// Call the set up and begin methods to fill the request object
callClientGlobalBegin(request);
1.7 +26 -1
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebRequest.java 28 Aug 2002 21:03:34 -0000 1.6
+++ WebRequest.java 26 Sep 2002 16:43:32 -0000 1.7
@@ -65,6 +65,7 @@
import org.apache.cactus.client.authentication.AbstractAuthentication;
import org.apache.cactus.util.ChainedRuntimeException;
+import org.apache.cactus.util.WebConfiguration;
/**
* Contains all HTTP request data for a test case. It is the data that
@@ -159,6 +160,25 @@
private String redirectorName;
/**
+ * Cactus configuration
+ */
+ private WebConfiguration configuration;
+
+ /**
+ * @param theConfiguration the Cactus configuration
*/
+ public WebRequest(WebConfiguration theConfiguration)
+ {
+ this.configuration = theConfiguration;
+ }
+
+ /**
+ * @return the Cactus configuration
*/
+ protected WebConfiguration getConfiguration()
+ {
+ return this.configuration;
+ }
+
+ /**
* Override the redirector Name defined in <code>cactus.properties</code>.
* This is useful to define a per test case Name (for example, if some
* test case need to have authentication turned on and not other tests,
@@ -188,6 +208,11 @@
AbstractAuthentication theAuthenticationObject)
{
this.authentication = theAuthenticationObject;
+
+ // Sets the Cactus configuration. It is performed here so that
+ // Cactus users do not have to bother with setting it on the
+ // Authenrication object they create.
+ this.authentication.setConfiguration(getConfiguration());
}
/**
1.5 +24 -1
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/AbstractAuthentication.java
Index: AbstractAuthentication.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/AbstractAuthentication.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractAuthentication.java 15 Sep 2002 21:09:38 -0000 1.4
+++ AbstractAuthentication.java 26 Sep 2002 16:43:32 -0000 1.5
@@ -57,6 +57,7 @@
package org.apache.cactus.client.authentication;
import org.apache.cactus.WebRequest;
+import org.apache.cactus.util.Configuration;
/**
* This class was designed with the simple assumption that ALL authentication
@@ -89,6 +90,11 @@
protected String password;
/**
+ * Cactus configuration
+ */
+ private Configuration configuration;
+
+ /**
* @param theName user name of the Credential
* @param thePassword user password of the Credential
*/
@@ -97,6 +103,23 @@
setName(theName);
setPassword(thePassword);
}
+
+ /**
+ * Sets the Cactus configuration so that authentication methods
+ * can get access to Cactus configuration properties. For example,
+ * this is needed by the <code>FormAuthentication</code>.
+ *
* @param theConfiguration the Cactus configuration
*/
+ public void setConfiguration(Configuration theConfiguration)
+ {
+ this.configuration = theConfiguration;
+ }
+
+ /**
+ * @return the Cactus configuration
*/
+ public Configuration getConfiguration()
+ {
+ return this.configuration;
+ }
/**
* Sets the user name.
1.4 +14 -14
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FormAuthentication.java 17 Sep 2002 19:39:46 -0000 1.3
+++ FormAuthentication.java 26 Sep 2002 16:43:32 -0000 1.4
@@ -63,8 +63,7 @@
import org.apache.cactus.WebRequest;
import org.apache.cactus.client.HttpClientConnectionHelper;
import org.apache.cactus.util.ChainedRuntimeException;
-import org.apache.cactus.util.Configuration;
-import org.apache.cactus.util.ServletConfiguration;
+import org.apache.cactus.util.WebConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -175,17 +174,19 @@
if (this.securityCheckURL == null)
{
// Configure default
+ String stringUrl =
+ ((WebConfiguration) getConfiguration()).getContextURL()
+ + "/j_security_check";
+
try
{
- this.securityCheckURL = new URL(Configuration.getContextURL()
- + "/j_security_check");
+ this.securityCheckURL = new URL(stringUrl);
}
catch (MalformedURLException e)
{
throw new ChainedRuntimeException(
- "Unable to create default Security Check URL ["
- + Configuration.getConnectionHelper() + "/j_security_check"
- + "]");
+ "Unable to create default Security Check URL ["
+ + stringUrl + "]");
}
}
@@ -205,16 +206,14 @@
{
// Create a helper that will connect to a restricted resource.
- // FIXME: Form-based authentication only works when setting up
- // security on the Servlet Redirector. We need to make that
- // work with any redirector.
-
- String resource = ServletConfiguration.getServletRedirectorURL();
+ String resource =
+ ((WebConfiguration) getConfiguration()).getRedirectorURL();
HttpClientConnectionHelper helper =
new HttpClientConnectionHelper(resource);
// Make the connection using a default web request.
- HttpURLConnection connection = helper.connect(new WebRequest());
+ HttpURLConnection connection = helper.connect(
+ new WebRequest((WebConfiguration) getConfiguration()));
// Clean any existing session ID.
sessionId = null;
@@ -257,7 +256,8 @@
// Configure a web request with the JSESSIONID cookie,
// the username and the password.
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(
+ (WebConfiguration) getConfiguration());
request.addCookie(sessionIdCookieName, sessionId);
request.addParameter("j_username", getName(),
WebRequest.POST_METHOD);
1.6 +11 -4
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ServletHttpClient.java
Index: ServletHttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ServletHttpClient.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServletHttpClient.java 28 Aug 2002 19:51:42 -0000 1.5
+++ ServletHttpClient.java 26 Sep 2002 16:43:32 -0000 1.6
@@ -57,7 +57,7 @@
package org.apache.cactus.client;
import org.apache.cactus.WebRequest;
-import org.apache.cactus.util.ServletConfiguration;
+import org.apache.cactus.util.WebConfiguration;
/**
* Manage the logic for calling the Servlet redirector for executing a test on
@@ -70,6 +70,13 @@
public class ServletHttpClient extends AbstractHttpClient
{
/**
+ * @see AbstractHttpClient#AbstractHttpClient(WebConfiguration)
*/
+ public ServletHttpClient(WebConfiguration theConfiguration)
+ {
+ super(theConfiguration);
+ }
+
+ /**
* Return the redirector URL to connect to.
*
* @param theRequest Request data from the user. We need it here as the user
@@ -83,12 +90,12 @@
// Check if user has overriden the servlet redirector
if (theRequest.getRedirectorName() != null)
{
- url = ServletConfiguration.getContextURL() + "/"
+ url = this.configuration.getContextURL() + "/"
+ theRequest.getRedirectorName();
}
else
{
- url = ServletConfiguration.getServletRedirectorURL();
+ url = this.configuration.getRedirectorURL();
}
return url;
1.6 +11 -4
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/JspHttpClient.java
Index: JspHttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/JspHttpClient.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JspHttpClient.java 28 Aug 2002 19:50:39 -0000 1.5
+++ JspHttpClient.java 26 Sep 2002 16:43:32 -0000 1.6
@@ -57,7 +57,7 @@
package org.apache.cactus.client;
import org.apache.cactus.WebRequest;
-import org.apache.cactus.util.JspConfiguration;
+import org.apache.cactus.util.WebConfiguration;
/**
* Manage the logic for calling the JSP redirector for executing a test on
@@ -70,6 +70,13 @@
public class JspHttpClient extends AbstractHttpClient
{
/**
+ * @see AbstractHttpClient#AbstractHttpClient(WebConfiguration)
*/
+ public JspHttpClient(WebConfiguration theConfiguration)
+ {
+ super(theConfiguration);
+ }
+
+ /**
* Return the redirector URL to connect to.
*
* @param theRequest Request data from the user. We need it here as the user
@@ -83,12 +90,12 @@
// Check if user has overriden the servlet redirector
if (theRequest.getRedirectorName() != null)
{
- url = JspConfiguration.getContextURL() + "/"
+ url = this.configuration.getContextURL() + "/"
+ theRequest.getRedirectorName();
}
else
{
- url = JspConfiguration.getJspRedirectorURL();
+ url = this.configuration.getRedirectorURL();
}
return url;
1.2 +4 -2
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ClientInitializer.java
Index: ClientInitializer.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ClientInitializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClientInitializer.java 1 Sep 2002 17:04:30 -0000 1.1
+++ ClientInitializer.java 26 Sep 2002 16:43:32 -0000 1.2
@@ -85,14 +85,16 @@
/**
* Initialize Cactus client side once.
+ *
+ * @param theConfiguration the Cactus configuration
*/
- public static void initialize()
+ public static void initialize(Configuration theConfiguration)
{
if (isInitialized == false)
{
try
{
- String initializerClassName = Configuration.getInitializer();
+ String initializerClassName = theConfiguration.getInitializer();
if (initializerClassName != null)
{
1.4 +6 -4
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ConnectionHelperFactory.java
Index: ConnectionHelperFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/ConnectionHelperFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConnectionHelperFactory.java 28 Aug 2002 19:47:29 -0000 1.3
+++ ConnectionHelperFactory.java 26 Sep 2002 16:43:32 -0000 1.4
@@ -78,8 +78,10 @@
* in Cactus configuration or the default one
* (<code>JdkConnectionHelper</code>)
* @param theUrl the URL to connect to as a String
+ * @param theConfiguration the Cactus configuration
*/
- public static ConnectionHelper getConnectionHelper(String theUrl)
+ public static ConnectionHelper getConnectionHelper(String theUrl,
+ Configuration theConfiguration)
{
// Load the corresponding class
ConnectionHelper connectionHelper;
@@ -87,7 +89,7 @@
try
{
Class connectionHelperClass =
- Class.forName(Configuration.getConnectionHelper());
+ Class.forName(theConfiguration.getConnectionHelper());
Constructor constructor = connectionHelperClass.getConstructor(
new Class[] { String.class });
@@ -97,7 +99,7 @@
catch (Exception e)
{
throw new ChainedRuntimeException("Failed to load the ["
- + Configuration.getConnectionHelper()
+ + theConfiguration.getConnectionHelper()
+ "] ConnectionHelper " + "class", e);
}
1.12 +23 -7
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/AbstractHttpClient.java
Index: AbstractHttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/AbstractHttpClient.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractHttpClient.java 28 Aug 2002 19:43:27 -0000 1.11
+++ AbstractHttpClient.java 26 Sep 2002 16:43:32 -0000 1.12
@@ -66,6 +66,7 @@
import org.apache.cactus.client.authentication.AbstractAuthentication;
import org.apache.cactus.util.ChainedRuntimeException;
import org.apache.cactus.util.IoUtil;
+import org.apache.cactus.util.WebConfiguration;
/**
* Abstract class for performing the steps necessary to run a test. It involves
@@ -80,6 +81,10 @@
public abstract class AbstractHttpClient
{
/**
+ * Cactus configuration.
*/
+ protected WebConfiguration configuration;
+
+ /**
* Return the redirector URL to connect to.
*
* @param theRequest Request data from the user. We need it here as the user
@@ -89,6 +94,14 @@
protected abstract String getRedirectorURL(WebRequest theRequest);
/**
+ * Initialize the Http client.
+ *
* @param theConfiguration the Cactus configuration
*/
+ public AbstractHttpClient(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.
*
@@ -179,7 +192,7 @@
// Open the first connection to the redirector to execute the test on
// the server side
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
- getRedirectorURL(theRequest));
+ getRedirectorURL(theRequest), this.configuration);
HttpURLConnection connection = helper.connect(theRequest);
@@ -208,18 +221,21 @@
private WebTestResult callGetResult(
AbstractAuthentication theAuthentication) throws Throwable
{
- WebRequest resultsRequest = new WebRequest();
-
+ WebRequest resultsRequest = new WebRequest(this.configuration);
- // Add authentication details
resultsRequest.addParameter(HttpServiceDefinition.SERVICE_NAME_PARAM,
ServiceEnumeration.GET_RESULTS_SERVICE.toString(),
WebRequest.GET_METHOD);
- resultsRequest.setAuthentication(theAuthentication);
+
+ // Add authentication details
+ if (theAuthentication != null)
+ {
+ resultsRequest.setAuthentication(theAuthentication);
+ }
// Open the second connection to get the test results
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
- getRedirectorURL(resultsRequest));
+ getRedirectorURL(resultsRequest), this.configuration);
HttpURLConnection resultConnection = helper.connect(resultsRequest);
1.2 +31 -17
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JettyInitializer.java 8 Sep 2002 17:30:54 -0000 1.1
+++ JettyInitializer.java 26 Sep 2002 16:43:32 -0000 1.2
@@ -60,6 +60,7 @@
import org.apache.cactus.server.FilterTestRedirector;
import org.apache.cactus.server.ServletTestRedirector;
+import org.apache.cactus.util.BaseConfiguration;
import org.apache.cactus.util.ClassLoaderUtils;
import org.apache.cactus.util.Configuration;
import org.apache.cactus.util.FilterConfiguration;
@@ -107,20 +108,25 @@
// in its classpath (using the same mechanism as the Ant project is
// using to conditionally compile tasks).
+ // Create configuration objects
+ BaseConfiguration baseConfig = new BaseConfiguration();
+ ServletConfiguration servletConfig = new ServletConfiguration();
+ FilterConfiguration filterConfig = new FilterConfiguration();
+
// Create a Jetty Server object and configure a listener
- Object server = createServer();
+ Object server = createServer(baseConfig);
// Create a Jetty context.
- Object context = createContext(server);
+ Object context = createContext(server, baseConfig);
// Add the Cactus Servlet redirector
- addServletRedirector(context);
+ addServletRedirector(context, servletConfig);
// Add the Cactus Jsp redirector
addJspRedirector(context);
// Add the Cactus Filter redirector
- addFilterRedirector(context);
+ addFilterRedirector(context, filterConfig);
// Configure Jetty with an XML file if one has been specified on the
// command line.
@@ -139,17 +145,19 @@
/**
* Create a Jetty server object and configures a listener on the
* port defined in the Cactus context URL property.
- *
* @return the Jetty <code>Server</code> object
+ *
+ * @param theConfiguration the base Cactus configuration
* @return the
Jetty <code>Server</code> object
*
* @exception Exception if an error happens during initialization
*/
- public Object createServer() throws Exception
+ public Object createServer(Configuration theConfiguration)
+ throws Exception
{
// Create Jetty Server object
Class serverClass = ClassLoaderUtils.loadClass(
"org.mortbay.jetty.Server", this.getClass());
Object server = serverClass.newInstance();
- URL contextURL = new URL(Configuration.getContextURL());
+ URL contextURL = new URL(theConfiguration.getContextURL());
// Add a listener on the port defined in the Cactus configuration
server.getClass().getMethod("addListener",
@@ -163,15 +171,17 @@
* Create a Jetty Context. We use a <code>WebApplicationContext</code>
* because we need to use Servlet Filters.
*
- * @param theServer the Jetty Server object
* @return Object the
<code>WebApplicationContext</code> object
+ * @param theServer the Jetty Server object
* @param theConfiguration the
base Cactus configuration
+ * @return Object the <code>WebApplicationContext</code> object
*
* @exception Exception if an error happens during initialization
*/
- public Object createContext(Object theServer) throws Exception
+ public Object createContext(Object theServer,
+ Configuration theConfiguration) throws Exception
{
// Add a web application. This creates a WebApplicationContext.
// Note: We do not put any WEB-INF/, lib/ nor classes/ directory
// in the webapp.
- URL contextURL = new URL(Configuration.getContextURL());
+ URL contextURL = new URL(theConfiguration.getContextURL());
if (System.getProperty(CACTUS_JETTY_RESOURCE_DIR_PROPERTY) != null)
{
@@ -194,15 +204,17 @@
/**
* Adds the Cactus Servlet redirector configuration.
*
* @param theContext the Jetty context under which to add the
configuration
+ * @param theConfiguration the Cactus Servlet configuration
*
* @exception Exception if an error happens during initialization
*/
- public void addServletRedirector(Object theContext) throws Exception
+ public void addServletRedirector(Object theContext,
+ ServletConfiguration theConfiguration) throws Exception
{
theContext.getClass().getMethod("addServlet",
new Class[] { String.class, String.class, String.class })
.invoke(theContext, new Object[] {
- ServletConfiguration.getServletRedirectorName(),
- "/" + ServletConfiguration.getServletRedirectorName(),
+ theConfiguration.getRedirectorName(),
+ "/" + theConfiguration.getRedirectorName(),
ServletTestRedirector.class.getName() });
}
@@ -245,10 +257,12 @@
* Adds the Cactus Filter redirector configuration.
*
* @param theContext the Jetty context under which to add the configuration
+ * @param theConfiguration the Cactus Filter configuration
*
* @exception Exception if an error happens during initialization
*/
- public void addFilterRedirector(Object theContext) throws Exception
+ public void addFilterRedirector(Object theContext,
+ FilterConfiguration theConfiguration) throws Exception
{
if (System.getProperty(CACTUS_JETTY_RESOURCE_DIR_PROPERTY) != null)
{
@@ -261,7 +275,7 @@
Object filterHolder = handler.getClass().getMethod("defineFilter",
new Class[] { String.class, String.class })
.invoke(handler, new Object[] {
- FilterConfiguration.getFilterRedirectorName(),
+ theConfiguration.getRedirectorName(),
FilterTestRedirector.class.getName() });
filterHolder.getClass().getMethod("applyTo",
@@ -272,8 +286,8 @@
handler.getClass().getMethod("mapPathToFilter",
new Class[] { String.class, String.class })
.invoke(handler, new Object[] {
- "/" + FilterConfiguration.getFilterRedirectorName(),
- FilterConfiguration.getFilterRedirectorName() });
+ "/" + theConfiguration.getRedirectorName(),
+ theConfiguration.getRedirectorName() });
}
}
1.4 +4 -2
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestAbstractWebTestCase.java 30 Aug 2002 20:29:03 -0000 1.3
+++ TestAbstractWebTestCase.java 26 Sep 2002 16:43:32 -0000 1.4
@@ -57,6 +57,7 @@
import org.apache.cactus.WebRequest;
import org.apache.cactus.WebResponse;
import org.apache.cactus.client.ServletHttpClient;
+import org.apache.cactus.util.WebConfiguration;
/**
* Some Cactus unit tests for testing <code>AbstractWebTestCase</code> that
@@ -108,7 +109,8 @@
*/
protected void runTest() throws Throwable
{
- runGenericTest(new ServletHttpClient());
+ runGenericTest(new ServletHttpClient(
+ (WebConfiguration) getConfiguration()));
if (!this.isClientGlobalEndCalled)
{
1.7 +3 -3
jakarta-cactus/framework/src/java/share/org/apache/cactus/server/runner/ServletTestRunner.java
Index: ServletTestRunner.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/runner/ServletTestRunner.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletTestRunner.java 28 Aug 2002 19:53:13 -0000 1.6
+++ ServletTestRunner.java 26 Sep 2002 16:43:33 -0000 1.7
@@ -67,7 +67,7 @@
import junit.framework.Test;
import junit.framework.TestResult;
-import org.apache.cactus.util.Configuration;
+import org.apache.cactus.util.BaseConfiguration;
/**
* Helper servlet to start a JUnit Test Runner in a webapp.
@@ -119,7 +119,7 @@
// Set up default Cactus System properties so that there is no need
// to have a cactus.properties file in WEB-INF/classes
- System.setProperty(Configuration.CACTUS_CONTEXT_URL_PROPERTY,
+ System.setProperty(BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY,
"http://" + theRequest.getServerName() + ":"
+ theRequest.getServerPort()
+ theRequest.getContextPath());
1.8 +10 -13
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FilterConfiguration.java 7 Sep 2002 19:47:45 -0000 1.7
+++ FilterConfiguration.java 26 Sep 2002 16:43:33 -0000 1.8
@@ -66,7 +66,8 @@
*
* @see Configuration
*/
-public class FilterConfiguration extends Configuration
+public class FilterConfiguration extends BaseConfiguration
+ implements WebConfiguration
{
/**
* Name of the cactus property that specifies the name of the JSP
@@ -82,28 +83,24 @@
*
* @return the Filter redirector URL
*/
- public static String getFilterRedirectorURL()
+ public String getRedirectorURL()
{
- initialize();
-
- return getContextURL() + "/" + getFilterRedirectorName();
+ return getContextURL() + "/" + getRedirectorName();
}
/**
* @return the Filter redirector name
*/
- public static String getFilterRedirectorName()
+ public String getRedirectorName()
{
- initialize();
-
- String filterRedirectorName =
+ String redirectorName =
System.getProperty(CACTUS_FILTER_REDIRECTOR_NAME_PROPERTY);
- if (filterRedirectorName == null)
+ if (redirectorName == null)
{
- filterRedirectorName = "FilterRedirector";
+ redirectorName = "FilterRedirector";
}
- return filterRedirectorName;
+ return redirectorName;
}
}
1.8 +15 -2
jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java
Index: TestAbstractTestCaseInterceptorTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestAbstractTestCaseInterceptorTestCase.java 29 Aug 2002 19:55:24 -0000
1.7
+++ TestAbstractTestCaseInterceptorTestCase.java 26 Sep 2002 16:43:33 -0000
1.8
@@ -64,6 +64,9 @@
import org.apache.cactus.client.ClientException;
import org.apache.cactus.mock.MockHttpURLConnection;
+import org.apache.cactus.util.Configuration;
+import org.apache.cactus.util.ServletConfiguration;
+import org.apache.cactus.util.WebConfiguration;
/**
* Test <code>TestCase</code> class that intercepts all exceptions (and assert
@@ -101,6 +104,14 @@
}
/**
+ * @see AbstractTestCase#createConfiguration()
+ */
+ protected Configuration createConfiguration()
+ {
+ return new ServletConfiguration();
+ }
+
+ /**
* Intercepts running test cases to check for normal exceptions.
*
* @exception Throwable any error that occurred when calling the test method
@@ -112,7 +123,8 @@
try
{
// Call the begin method
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(
+ (WebConfiguration) getConfiguration());
callBeginMethod(request);
@@ -306,4 +318,5 @@
return false;
}
+
}
1.7 +12 -11
jakarta-cactus/framework/src/test/share/org/apache/cactus/TestWebRequest.java
Index: TestWebRequest.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestWebRequest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestWebRequest.java 30 Aug 2002 20:05:58 -0000 1.6
+++ TestWebRequest.java 26 Sep 2002 16:43:33 -0000 1.7
@@ -61,6 +61,7 @@
import junit.framework.TestCase;
import org.apache.cactus.util.ChainedRuntimeException;
+import org.apache.cactus.util.ServletConfiguration;
/**
* Unit tests of the <code>WebRequest</code> class.
@@ -96,7 +97,7 @@
*/
public void testAddParameterInvalidMethod()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
try
{
@@ -116,7 +117,7 @@
*/
public void testGetParametersGetOk()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addParameter("param1", "value1", WebRequest.GET_METHOD);
request.addParameter("param1", "value2", WebRequest.GET_METHOD);
@@ -132,7 +133,7 @@
*/
public void testGetParameterGetNull()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addParameter("param1", "value1", WebRequest.POST_METHOD);
@@ -147,7 +148,7 @@
*/
public void testGetParametersPostOk()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addParameter("param1", "value1", WebRequest.POST_METHOD);
request.addParameter("param1", "value2", WebRequest.POST_METHOD);
@@ -163,7 +164,7 @@
*/
public void testGetParameterPostNull()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addParameter("param1", "value1", WebRequest.GET_METHOD);
@@ -178,7 +179,7 @@
*/
public void testGetHeaderOk()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addHeader("header1", "value1");
request.addHeader("header2", "value2");
@@ -194,7 +195,7 @@
*/
public void testGetHeaderNull()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
String result = request.getHeader("header1");
@@ -207,7 +208,7 @@
*/
public void testToString()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addHeader("header1", "value1");
request.addHeader("header1", "value2");
@@ -239,7 +240,7 @@
*/
public void testSetURLBadQueryString()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
try
{
@@ -259,7 +260,7 @@
*/
public void testGetPostParametersSeveral()
{
- WebRequest request = new WebRequest();
+ WebRequest request = new WebRequest(new ServletConfiguration());
request.addParameter("param1", "value1", WebRequest.POST_METHOD);
request.addParameter("param2", "value2", WebRequest.POST_METHOD);
1.5 +14 -2
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FilterTestCase.java 27 Aug 2002 23:11:15 -0000 1.4
+++ FilterTestCase.java 26 Sep 2002 16:43:33 -0000 1.5
@@ -61,6 +61,9 @@
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
@@ -128,6 +131,15 @@
*/
protected void runTest() throws Throwable
{
- runGenericTest(new FilterHttpClient());
+ runGenericTest(new FilterHttpClient(
+ (WebConfiguration) getConfiguration()));
+ }
+
+ /**
+ * @see AbstractTestCase#createConfiguration()
+ */
+ protected Configuration createConfiguration()
+ {
+ return new FilterConfiguration();
}
}
1.7 +12 -4
jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/client/FilterHttpClient.java
Index: FilterHttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/client/FilterHttpClient.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FilterHttpClient.java 27 Aug 2002 23:02:49 -0000 1.6
+++ FilterHttpClient.java 26 Sep 2002 16:43:33 -0000 1.7
@@ -57,7 +57,7 @@
package org.apache.cactus.client;
import org.apache.cactus.WebRequest;
-import org.apache.cactus.util.FilterConfiguration;
+import org.apache.cactus.util.WebConfiguration;
/**
* Manage the logic for calling the Servlet redirector for executing a test on
@@ -70,6 +70,14 @@
public class FilterHttpClient extends AbstractHttpClient
{
/**
+ * @see AbstractHttpClient#AbstractHttpClient(WebConfiguration)
+ */
+ public FilterHttpClient(WebConfiguration theConfiguration)
+ {
+ super(theConfiguration);
+ }
+
+ /**
* Return the redirector URL to connect to.
*
* @param theRequest Request data from the user. We need it here as the user
@@ -83,12 +91,12 @@
// Check if user has overriden the servlet redirector
if (theRequest.getRedirectorName() != null)
{
- url = FilterConfiguration.getContextURL() + "/"
+ url = this.configuration.getContextURL() + "/"
+ theRequest.getRedirectorName();
}
else
{
- url = FilterConfiguration.getFilterRedirectorURL();
+ url = this.configuration.getRedirectorURL();
}
return url;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>