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 2003/10/19 20:06:47 UTC
cvs commit: jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/server FilterTestRedirector.java
vmassol 2003/10/19 11:06:47
Modified: framework build.xml logging.properties.sample
framework/src/java/share/org/apache/cactus/server
ServletTestRedirector.java JspTestRedirector.java
framework/src/test/share/org/apache/cactus
AbstractTestAbstractTestCase.java TestAll.java
framework/src/java/share/org/apache/cactus/configuration
BaseConfiguration.java
framework/src/java/share/org/apache/cactus
ServletTestCase.java JspTestCase.java
framework/src/java/j2ee13/org/apache/cactus
FilterTestCase.java
framework/src/java/j2ee13/org/apache/cactus/server
FilterTestRedirector.java
Added: framework/src/java/share/org/apache/cactus/configuration
ConfigurationInitializer.java
Log:
Make logging system really work. Tested with JDK 1.4, Log4j and simple logging. Also tested with several app server
Revision Changes Path
1.72 +6 -2 jakarta-cactus/framework/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/build.xml,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- build.xml 13 Oct 2003 20:47:40 -0000 1.71
+++ build.xml 19 Oct 2003 18:06:46 -0000 1.72
@@ -98,6 +98,7 @@
<echo> httpunit.jar = [${httpunit.jar}]</echo>
<echo> j2ee.jar = [${j2ee.jar}]</echo>
<echo> junit.jar = [${junit.jar}]</echo>
+ <echo> log4j.jar = [${log4j.jar}]</echo>
<echo> xmlapis.jar (optional) = [${xmlapis.jar}]</echo>
<echo/>
<echo>Options:</echo>
@@ -121,6 +122,7 @@
<available file="${httpunit.jar}"/>
<available file="${j2ee.jar}"/>
<available file="${junit.jar}"/>
+ <available file="${log4j.jar}"/>
<!-- Check for a TraX class instead of the xmlapis.jar file so that
the build works on JDK 1.4 without needing to define the
xmlapis.jar property -->
@@ -380,6 +382,7 @@
<pathelement path="${target.classes.clover.dir}"/>
<pathelement path="${target.classes.test.dir}"/>
<pathelement location="${clover.jar}"/>
+ <pathelement location="${log4j.jar}"/>
<path refid="project.classpath"/>
</path>
@@ -391,6 +394,7 @@
<path id="test.class.path">
<pathelement path="${target.classes.java.dir}"/>
<pathelement path="${target.classes.test.dir}"/>
+ <pathelement location="${log4j.jar}"/>
<path refid="project.classpath"/>
</path>
@@ -418,7 +422,7 @@
<junit printsummary="yes" haltonfailure="yes" fork="yes">
<sysproperty key="cactus.logging.config"
- file="${target.dir}/logging.properties"/>
+ value="${target.dir.normalized}/logging.properties"/>
<classpath>
<path refid="test.class.path"/>
</classpath>
1.4 +55 -12 jakarta-cactus/framework/logging.properties.sample
Index: logging.properties.sample
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/logging.properties.sample,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- logging.properties.sample 13 Oct 2003 20:54:21 -0000 1.3
+++ logging.properties.sample 19 Oct 2003 18:06:46 -0000 1.4
@@ -4,25 +4,68 @@
# Disable logging by default when running the tests. If you wish to use a
# logging subsystem, uncomment the line below. That will let Commons logging
-# decide automatically of a suitable logging system for you. For more info, see
+# decide automatically of a suitable logging system for you. You can also force
+# commons-logging to use a specific logging system. For more info, see
# http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/package-summary.html#package_description
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
+
+# Disable logging
+#org.apache.commons.logging.Log = org.apache.commons.logging.impl.NoOpLog
+
+# Force to use JDK 1.4 logging
+#org.apache.commons.logging.Log = org.apache.commons.logging.impl.Jdk14Logger
+
+# Force to use Log4J logging
+#org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger
+
+# Force to use Simple logging
+#org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog
# ---- JDK 1.4 logging properties
# Following properties are useful if you're using the JDK 1.4 logging subsystem
-# and wish to output logs to the console. Comment the NoOpLog line above and
-# uncommment the following lines as needed.
+# and wish to output logs to a file. Make sure to comment out the NoOpLog line
+# above.
java.util.logging.config.file = @target.dir@/logging.properties
-handlers = java.util.logging.FileHandler,java.util.logging.ConsoleHandler
-java.util.logging.ConsoleHandler.level = FINEST
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-java.util.logging.FileHandler.pattern = @target.dir@/test%u.log
-java.util.logging.FileHandler.limit = 50000
-java.util.logging.FileHandler.count = 1
+handlers = java.util.logging.FileHandler
+java.util.logging.FileHandler.pattern = @target.dir@/test.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
# If you want to provide finer grained logging, restrict the level for the
# specific package name.
-# For example: org.apache.cactus.server.level = FINEST
-org.apache.cactus.level = FINEST
+# For example:
+# org.apache.cactus.server.level = ALL
+# org.apache.commons.httpclient.level = ALL
+# .level = ALL
+org.apache.cactus.level = ALL
+
+# ---- Log4J logging properties
+
+# Following properties are useful if you're using the Log4J logging subsystem
+# and wish to output logs to a file. Make sure to comment out the NoOpLog line
+# above.
+log4j.configuration = file:/@target.dir@/logging.properties
+
+log4j.appender.cactus = org.apache.log4j.FileAppender
+log4j.appender.cactus.File = @target.dir@/test.log
+log4j.appender.cactus.Append = false
+log4j.appender.cactus.layout = org.apache.log4j.PatternLayout
+log4j.appender.cactus.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p %-30.30c{2} %x - %m %n
+
+# Any application log which uses Log4J will be logged to the Cactus log file
+log4j.rootCategory=DEBUG, cactus
+
+# Debug logs for Cactus
+log4j.category.org.apache.cactus = DEBUG, cactus
+log4j.additivity.org.apache.cactus = false
+
+# Debug logs for HttpClient
+log4j.category.org.apache.commons.httpclient = DEBUG, cactus
+log4j.additivity.org.apache.commons.httpclient = false
+log4j.category.httpclient = WARN, cactus
+log4j.additivity.httpclient = false
+
+# ---- SimpleLog logging properties
+
+org.apache.commons.logging.simplelog.showlogname = true
+org.apache.commons.logging.simplelog.log.org.apache.cactus = trace
+org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient = trace
1.7 +14 -1 jakarta-cactus/framework/src/java/share/org/apache/cactus/server/ServletTestRedirector.java
Index: ServletTestRedirector.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/ServletTestRedirector.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletTestRedirector.java 26 May 2003 11:45:22 -0000 1.6
+++ ServletTestRedirector.java 19 Oct 2003 18:06:46 -0000 1.7
@@ -61,6 +61,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -74,6 +75,18 @@
*/
public class ServletTestRedirector extends HttpServlet
{
+ /**
+ * As this class is the first one loaded on the server side, we ensure
+ * that the Cactus configuration has been initialized. A better
+ * implementation might be to perform this initialization in the
+ * init() method. However, that requires removing the static LOGGER
+ * object.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
/**
* The logger
*/
1.7 +15 -2 jakarta-cactus/framework/src/java/share/org/apache/cactus/server/JspTestRedirector.java
Index: JspTestRedirector.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/JspTestRedirector.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JspTestRedirector.java 26 May 2003 11:45:22 -0000 1.6
+++ JspTestRedirector.java 19 Oct 2003 18:06:46 -0000 1.7
@@ -58,12 +58,13 @@
import javax.servlet.ServletException;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Extension of the <code>jspRedirector.jsp</code> JSP Redirector in the java
- * realmn in order to provide a symmetry with the <code>ServletRedirector</code>
+ * realm in order to provide a symmetry with the <code>ServletRedirector</code>
* and minimize the amount of java code in <code>jspRedirector.jsp</code>.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
@@ -72,6 +73,18 @@
*/
public class JspTestRedirector
{
+ /**
+ * As this class is the first one loaded on the server side, we ensure
+ * that the Cactus configuration has been initialized. A better
+ * implementation might be to perform this initialization in the
+ * init() method. However, that requires removing the static LOGGER
+ * object.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
/**
* The logger
*/
1.2 +2 -2 jakarta-cactus/framework/src/test/share/org/apache/cactus/AbstractTestAbstractTestCase.java
Index: AbstractTestAbstractTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/AbstractTestAbstractTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractTestAbstractTestCase.java 21 Sep 2003 09:05:48 -0000 1.1
+++ AbstractTestAbstractTestCase.java 19 Oct 2003 18:06:46 -0000 1.2
@@ -80,7 +80,7 @@
* @version $Id$
*/
public abstract class AbstractTestAbstractTestCase extends TestCase
-{
+{
/**
* Override default method so that configuration checks are not run during
* these unit tests.
1.15 +4 -4 jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAll.java
Index: TestAll.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAll.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestAll.java 13 Oct 2003 20:28:40 -0000 1.14
+++ TestAll.java 19 Oct 2003 18:06:46 -0000 1.15
@@ -56,7 +56,7 @@
*/
package org.apache.cactus;
-import org.apache.cactus.configuration.BaseConfiguration;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -86,8 +86,8 @@
// Make sure logging configuration properties are initialized so
// that it is possible to control logging from the outside of the
// tests.
- new BaseConfiguration();
-
+ ConfigurationInitializer.initialize();
+
suite.addTestSuite(TestAbstractTestCase.class);
suite.addTestSuite(TestServletURL.class);
suite.addTestSuite(TestServletUtil.class);
1.6 +2 -152 jakarta-cactus/framework/src/java/share/org/apache/cactus/configuration/BaseConfiguration.java
Index: BaseConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/configuration/BaseConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseConfiguration.java 13 Oct 2003 20:28:40 -0000 1.5
+++ BaseConfiguration.java 19 Oct 2003 18:06:47 -0000 1.6
@@ -56,23 +56,13 @@
*/
package org.apache.cactus.configuration;
-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.connector.http.HttpClientConnectionHelper;
import org.apache.cactus.util.ChainedRuntimeException;
-import org.apache.cactus.util.ClassLoaderUtils;
/**
* 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.
+ * Properties.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
@@ -81,19 +71,6 @@
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.
@@ -124,133 +101,10 @@
"cactus.initializer";
/**
- * Name of the Cactus property that points to a properties file
- * containing logging configuration.
- */
- private static final String CACTUS_LOGGING_CONFIG_PROPERTY =
- "cactus.logging.config";
-
- /**
- * Initialize all Cactus configuration properties.
- */
- public BaseConfiguration()
- {
- initialize();
- }
-
- /**
- * Initialize all configurations properties.
- */
- private void initialize()
- {
- initializeConfig();
- initializeLoggingConfig();
- }
-
- /**
- * Initialize general cactus configuration. 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 void initializeConfig()
- {
- 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);
- }
- }
-
- addSystemProperties(config);
- }
-
- /**
- * Initialize logging configuration.
- */
- public void initializeLoggingConfig()
- {
- String logConfig = System.getProperty(CACTUS_LOGGING_CONFIG_PROPERTY);
- if (logConfig != null)
- {
- ResourceBundle bundle;
- try
- {
- bundle = new PropertyResourceBundle(
- new FileInputStream(logConfig));
- }
- catch (IOException e)
- {
- throw new ChainedRuntimeException("Failed to load logging "
- + "configuration file [" + logConfig + "]");
- }
- addSystemProperties(bundle);
- }
- }
-
- /**
- * Add all properties found in the resource bundle as system
- * properties.
- *
- * @param theBundle the resource bundle containing the properties to
- * set as system properties
- */
- private void addSystemProperties(ResourceBundle theBundle)
- {
- Enumeration keys = theBundle.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, theBundle.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);
@@ -271,8 +125,6 @@
*/
public String getConnectionHelper()
{
- initialize();
-
// Try to read it from a System property first and then if not defined
// use the default.
String connectionHelperClassname =
@@ -294,8 +146,6 @@
*/
public String getInitializer()
{
- initialize();
-
return System.getProperty(CACTUS_INITIALIZER_PROPERTY);
}
}
1.1 jakarta-cactus/framework/src/java/share/org/apache/cactus/configuration/ConfigurationInitializer.java
Index: ConfigurationInitializer.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.configuration;
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.util.ChainedRuntimeException;
import org.apache.cactus.util.ClassLoaderUtils;
/**
* Read Cactus configuration files and set the properties found as
* System properties.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: ConfigurationInitializer.java,v 1.1 2003/10/19 18:06:47 vmassol Exp $
*/
public class ConfigurationInitializer
{
/**
* 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 the Cactus property that points to a properties file
* containing logging configuration.
*/
private static final String CACTUS_LOGGING_CONFIG_PROPERTY =
"cactus.logging.config";
/**
* Have the Cactus configuration files been initialized?
*/
private static boolean isInitialized;
/**
* Read Cactus configuration files.
*/
public static final synchronized void initialize()
{
if (!isInitialized)
{
initializeConfig();
initializeLoggingConfig();
isInitialized = true;
}
}
/**
* Initialize general cactus configuration. 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 static final void initializeConfig()
{
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, ConfigurationInitializer.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);
}
}
addSystemProperties(config);
}
/**
* Initialize logging configuration.
*/
private static final void initializeLoggingConfig()
{
String logConfig = System.getProperty(CACTUS_LOGGING_CONFIG_PROPERTY);
if (logConfig != null)
{
ResourceBundle bundle;
try
{
bundle = new PropertyResourceBundle(
new FileInputStream(logConfig));
}
catch (IOException e)
{
throw new ChainedRuntimeException("Failed to load logging "
+ "configuration file [" + logConfig + "]");
}
addSystemProperties(bundle);
}
}
/**
* Add all properties found in the resource bundle as system
* properties.
*
* @param theBundle the resource bundle containing the properties to
* set as system properties
*/
private static void addSystemProperties(ResourceBundle theBundle)
{
Enumeration keys = theBundle.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, theBundle.getString(key));
}
}
}
}
1.17 +14 -1 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ServletTestCase.java 31 Aug 2003 14:17:57 -0000 1.16
+++ ServletTestCase.java 19 Oct 2003 18:06:47 -0000 1.17
@@ -62,6 +62,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.cactus.configuration.ServletConfiguration;
import org.apache.cactus.internal.client.WebClientTestCaseDelegate;
import org.apache.cactus.internal.server.ServerTestCaseDelegate;
@@ -78,6 +79,18 @@
*/
public class ServletTestCase extends TestCase
{
+ /**
+ * As this class is the first one loaded on the client side, we ensure
+ * that the Cactus configuration has been initialized. In the future,
+ * this block will be removed as all initialization will be done in Cactus
+ * test suites. However, as we still support using Cactus TestCase classes
+ * we don't a proper initialization hook and thus we need this hack.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
/**
* Valid <code>HttpServletRequest</code> object that you can access from
* the <code>testXXX()</code>, <code>setUp</code> and
1.14 +14 -1 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JspTestCase.java 12 Jul 2003 19:31:41 -0000 1.13
+++ JspTestCase.java 19 Oct 2003 18:06:47 -0000 1.14
@@ -60,6 +60,7 @@
import junit.framework.Test;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.cactus.configuration.JspConfiguration;
import org.apache.cactus.internal.client.WebClientTestCaseDelegate;
import org.apache.cactus.internal.server.ServerTestCaseDelegate;
@@ -76,6 +77,18 @@
*/
public class JspTestCase extends ServletTestCase
{
+ /**
+ * As this class is the first one loaded on the client side, we ensure
+ * that the Cactus configuration has been initialized. In the future,
+ * this block will be removed as all initialization will be done in Cactus
+ * test suites. However, as we still support using Cactus TestCase classes
+ * we don't a proper initialization hook and thus we need this hack.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
/**
* Valid <code>PageContext</code> object that you can access from
* the <code>testXXX()</code>, <code>setUp</code> and
1.19 +14 -1 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- FilterTestCase.java 31 Aug 2003 14:17:57 -0000 1.18
+++ FilterTestCase.java 19 Oct 2003 18:06:47 -0000 1.19
@@ -62,6 +62,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.cactus.configuration.FilterConfiguration;
import org.apache.cactus.internal.client.WebClientTestCaseDelegate;
import org.apache.cactus.internal.server.ServerTestCaseDelegate;
@@ -78,6 +79,18 @@
*/
public class FilterTestCase extends TestCase
{
+ /**
+ * As this class is the first one loaded on the client side, we ensure
+ * that the Cactus configuration has been initialized. In the future,
+ * this block will be removed as all initialization will be done in Cactus
+ * test suites. However, as we still support using Cactus TestCase classes
+ * we don't a proper initialization hook and thus we need this hack.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
// TODO: Find a way to factorize FilterTestCase and ServletTestCase
/**
1.8 +14 -1 jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/server/FilterTestRedirector.java
Index: FilterTestRedirector.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/server/FilterTestRedirector.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FilterTestRedirector.java 26 May 2003 11:43:46 -0000 1.7
+++ FilterTestRedirector.java 19 Oct 2003 18:06:47 -0000 1.8
@@ -67,6 +67,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.cactus.configuration.ConfigurationInitializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -80,6 +81,18 @@
*/
public class FilterTestRedirector implements Filter
{
+ /**
+ * As this class is the first one loaded on the server side, we ensure
+ * that the Cactus configuration has been initialized. A better
+ * implementation might be to perform this initialization in the
+ * init() method. However, that requires removing the static LOGGER
+ * object.
+ */
+ static
+ {
+ ConfigurationInitializer.initialize();
+ }
+
/**
* The logger
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org