Thanks, Craig. As you probably know, I posted a similar message
over on the Struts-Shale list.
So it
appears that, unlike Cactus, the Shale Test Framework doesn't run in the
Web containers, correct? Is there any testing framework I can use that
will run in the Web container so that I can effectively initiate a J2EE
round-trip test starting with my JSF managed bean's action
method?
Brendan Conner
Contractor - IT
National Data
847-248-1519 (Office)
-----Original Message-----On 2/14/06, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig McClanahan
Sent: Tuesday, February 14, 2006 5:58 PM
To: MyFaces Discussion
Subject: Re: Using Shale Test Framework with MyFacesThanks. Is it an appropriate framework to use for application-level
tests?
For example, to test a managed bean's action method that does something
like the following:
1. Gets values from two or three managed beans
No problem ... the framework mocks the managed bean system and (at least limited) evaluation of value binding and method binding expressions.
2. Looks up the "selected record" from a DataModel object within one of
the beans
Presuming that you've got your DataModel configured with an appropriate database connection, this should work.
3. Performs a JNDI lookup of a Session Bean
JNDI lookups are not currently supported. It would be pretty straightforward to mock up a JNDI InitialContext for something like a DataSource; but the framework doesn't pretend to implement anything EJB-ish. If we go ahead and and created a MockInitialContext, you might consider setting up mocks for your Session Beans -- we could convincingly fake the JNDI lookup part, but not the EJB behavior part. I wouldn't even want to *think* about emulating all that, unless we were talking EJB3 with out-of-the-container execution abilities.
4. Invokes the Session Bean to insert something into the database
Limited by the previous issue.
5. Queues a message to FacesContext
That part will work.
6. Returns an outcome string
So will that ... you can have a JUnit test method do assertions on the outcome returned when you call the action method.
- Brendan
Craig