Raymond Feng wrote:
Hi,
In the WAR-based Tuscany deployment, the TuscanyServletFilter is
responsible to start/stop the SCADomain. At this moment, most of our
itest cases create the SCADomain using SCADomain.newInstance() during
the setup. If we run itests as a webapp, it ends up with two different
domain instances.
To really test the webapp scheme, the itests should use the SCADomain
created by the TuscanyServletFilter. I propose that we convert the
itests using the following pattern so that they can be run under both
J2SE and Webapp.
For the test case:
1) Declare a static field typed by SCADomain
2) Test if it is null before creating a new instance (it will be
injected under Webapp)
For the runtime:
1) WebAppServletHost will subclass SCADomain so that SCADomain.close()
will only happen during the TuscanyServletFilter.destroy() and the
SCADomain.close() statement in itest doesn't really shutdown the domain.
2) The JUnitServletFilter will get the SCADomain attribute from the
ServletContext and try to inject it into the test case class.
Here is an example of the itest.
public class XYZServiceTestCase extends TestCase {
private static SCADomain scaDomain; // A static field which can be
injected
private MyService service;
protected void setUp() throws Exception {
if (scaDomain == null) {
// J2SE case
scaDomain = SCADomain.newInstance("XYZ.composite");
}
service = scaDomain.getService(MyService.class, "MyComponent");
}
protected void tearDown() throws Exception {
scaDomain.close();
}
}
What do you guys think?
Thanks,
Raymond
+1 to all that except for the "WebAppServletHost will subclass SCADomain
so that SCADomain.close() will only happen during the
TuscanyServletFilter.destroy() and the SCADomain.close() statement in
itest doesn't really shutdown the domain." part.
A "close that doesn't really close" is a recipe for confusion and
trouble IMO and feels like a runtime that doesn't really run...
I'd prefer close to throw an exception like "It is illegal for you to
close that domain as it was created by and owned by somebody else" and
have the test case consciously catch that exception.
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]