Grégory Joseph ha scritto:
Essentially, what you're asking is if there's a way to get an object out
of a running web-app, from outside the container that runs said web-app.
Unless you expose the object in question through mechanisms such as jmx,
rmi, jndi or other forms of webservices, the answer is no ;)
In our "tests", as far as I can remember, what we do is somehow manage
to get some predictable output from the webapp the tests deploy (i.e a
template that prints out the content of the context's attributes for
instance) and in the test, compare that output with what we expect. It's
not exactly satisfying nor very flexible, .. nor very easy/fast to work
with. If you come up with other ideas, please share!
I Grég, nice point.
I have 3 observation:
1) Using Jetty is possible to have a webapp container context
programmatically.
*****
WebAppContext jettyCtx = new WebAppContext(server, WEBAPPDIR,
"/magnoliaAuthor");
ServletContext sc = jettyCtx.getServletContext();
HttpServletRequest request = createStrictMock(HttpServletRequest.class);
HttpServletResponse response = createStrictMock(HttpServletResponse.class);
WebContext webCtx = ContextFactory.getInstance().createWebContext(
request, response, sc);
MgnlContext.setInstance(webCtx);
***
But when we try to create a Magnolia Context using the factory, it fails.
So, is it possible to transform a generic context in a Magnolia Context?
2) Think about scheduled jobs. They are command executed during normal
webapp lifecycle, without passing from request / response mechanism.
The idea is to launch a test very similar to that scheduled job...
3) Ok, if we can not obtain MgnlContext instance and consequentially
have repository access, we can manage to use Selenium to automatically
launch interaction test within testNG / jUnit.
But I agree with you, expecially for small/medium project, the effort is
too much.
Matteo
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------