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 2004/04/14 08:55:34 UTC
cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus/server/runner ServletTestRunner.java
vmassol 2004/04/13 23:55:34
Modified: documentation/docs/xdocs changes.xml
framework/src/java/share/org/apache/cactus/server/runner
ServletTestRunner.java
Log:
The <code>ServletTestRunner</code> now looks for am optional <code>cactus.properties</code> file and reads its properties. If not defined it sets default values for the context URL of the Cactus redirectors and for their mappings.
Revision Changes Path
1.185 +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.184
retrieving revision 1.185
diff -u -r1.184 -r1.185
--- changes.xml 13 Apr 2004 12:38:46 -0000 1.184
+++ changes.xml 14 Apr 2004 06:55:34 -0000 1.185
@@ -91,6 +91,12 @@
<release version="1.6dev" date="in CVS">
<action dev="VMA" type="update">
+ The <code>ServletTestRunner</code> now looks for am optional
+ <code>cactus.properties</code> file and reads its properties. If
+ not defined it sets default values for the context URL of the
+ Cactus redirectors and for their mappings.
+ </action>
+ <action dev="VMA" type="update">
Updated web site documentation for enabling Cactus logging.
</action>
<action dev="VMA" type="update">
1.20 +43 -16 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ServletTestRunner.java 10 Apr 2004 15:52:16 -0000 1.19
+++ ServletTestRunner.java 14 Apr 2004 06:55:34 -0000 1.20
@@ -38,6 +38,7 @@
import junit.framework.TestResult;
import org.apache.cactus.internal.configuration.BaseConfiguration;
+import org.apache.cactus.internal.configuration.ConfigurationInitializer;
import org.apache.cactus.internal.server.runner.WebappTestRunner;
import org.apache.cactus.internal.server.runner.XMLFormatter;
@@ -56,6 +57,18 @@
public class ServletTestRunner 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();
+ }
+
+ /**
* HTTP parameter containing name of test suite to execute
*/
private static final String HTTP_SUITE_PARAM = "suite";
@@ -214,7 +227,9 @@
/**
* Set up default Cactus System properties so that there is no need
- * to have a cactus.properties file in WEB-INF/classes.
+ * to have a <code>cactus.properties</code> file in WEB-INF/classes.
+ * However, if a <code>cactus.properties</code> file is found, the
+ * properties are read from it.
*
* Note: If the JVM security policy prevents setting System properties
* you will still need to provide a cactus.properties file.
@@ -224,22 +239,34 @@
*/
private void setSystemProperties(HttpServletRequest theRequest)
{
- if (this.canSetSystemProperty)
+ // TODO: We cannot call BaseConfiguration.getContextURL() as it
+ // throws an exception if the context URL property is not defined.
+ // It would be good to change that behavior for a better reuse
+ String contextURL = System.getProperty(
+ BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY);
+
+ // If the context URL propety has not been set, we set a default
+ // value based on the ServletTestRunner mapping in the web app.
+ if (contextURL == null)
{
- try
+ if (this.canSetSystemProperty)
{
- System.setProperty(
- BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY,
- "http://" + theRequest.getServerName() + ":"
- + theRequest.getServerPort()
- + theRequest.getContextPath());
- }
- catch (SecurityException se)
- {
- log("Could not set the Cactus context URL as system property, "
- + "you will have to include a Cactus properties file in "
- + "the class path of the web application", se);
- this.canSetSystemProperty = false;
+ try
+ {
+ System.setProperty(
+ BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY,
+ "http://" + theRequest.getServerName() + ":"
+ + theRequest.getServerPort()
+ + theRequest.getContextPath());
+ }
+ catch (SecurityException se)
+ {
+ log("Could not set the Cactus context URL as system "
+ + "property, you will have to include a Cactus "
+ + "properties file in the class path of the web "
+ + "application", se);
+ this.canSetSystemProperty = false;
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org