jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kazuhito SUGURI <suguri.kazuh...@lab.ntt.co.jp>
Subject Re: ServletTestRunner and multiple Web Applications
Date Sat, 19 Jun 2004 17:51:47 GMT
Hi Vincent,

In article <055101c45603$cbd91a30$64eafb0a@vma>,
Sat, 19 Jun 2004 15:46:16 +0200,
"Vincent Massol" <vmassol@pivolis.com> wrote: 
vmassol> This means that it was pure luck that Cactus was working for you
vmassol> before... ;-)


vmassol> Also, the call to setSystemProperties() happen in the doGet() method,
vmassol> i.e. for each call to the Servlet Test Runner. Thus, if the contextURL
vmassol> property changes, it should work fine, no? It means that you would need
vmassol> to change this property between your 2 webapp tests, which seems normal
vmassol> to me. What am I missing?

The following is extracted from ServeltTestRunner#setSystemProperties()
of Cactus-1.6.1:
        String contextURL = System.getProperty(

        if (contextURL == null)
                        "http://" + theRequest.getServerName() + ":"
                        + theRequest.getServerPort()
                        + theRequest.getContextPath());
The lifetime of the System object may be the point.
I think, but not sure, once the contextURL property is set
for the first test, the same property value may be used for other tests
if the server is not re-started.

One more thing. One may try to set the contextURL System property
for each app by using WEB-INF/classes/cactus.properties.
However, ConfigurationInitializer#initialize() will not update
the System property if it already exists.
So, I think, once a ServletTestRunner of app1 set the cntextURL property,
no other apps can change that.

A way to solve this is to change ServeltTestRunner#setSystemProperties()
method as like as follows (shows core logic only): 
	ResourceBundle config = PropertyResourceBundle.getBundle("cactus");
	String contextURL = config.getString(BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY);
	if (contextURL == null)
	    contextURL = "http://" + theRequest.getServerName() + ":"
	                + theRequest.getServerPort()
	                + theRequest.getContextPath();


What do you think?
Kazuhito SUGURI

View raw message