For what it's worth. This seems to be a known problem with the Shale
test framework. It may be that it's fixed for the upcoming 1.1 release
in the ConfigParser helper class
(https://issues.apache.org/struts/browse/SHALE-262). I have no insight
into when this functionality will be released.
Can anyone recommend a workaround in the mean time?
Ain't life grand on the bleeding edge?
Steve
On 5/28/2007 5:43 PM, Steve Tynor wrote:
I'm making some progress in getting the JSF 1.2 unit tests to run by
using the shale-test framework as Matt suggested last week. I'm stuck
now with the FacesUtils.getManagedBean() function returning null.
Can someone more familiar with either Shale-test or JSF help me out here?
In PasswordHintTest, the following call returns null:
public void setUp() throws Exception {
super.setUp();
---->>>> bean = (PasswordHint) getManagedBean("passwordHint");
}
I've added the following dependency to pom.xml:
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-test</artifactId>
<version>1.0.4</version>
</dependency>
I include the modified BasePageTest source -- there are some mechanical
changes to its descendent classes to call the new non-default
constructor required by the Shale test baseclass and to call
super.tearDown() in each tearDown class as recommended by the shale doc.
Thanks,
Steve
--------------------------------
package org.appfuse.webapp.action;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shale.test.base.AbstractJsfTestCase;
import org.appfuse.Constants;
import org.appfuse.webapp.util.FacesUtils;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public abstract class BasePageTestCase extends AbstractJsfTestCase {
protected final Log log = LogFactory.getLog(getClass());
protected static final String MESSAGES = Constants.BUNDLE_KEY;
protected static WebApplicationContext applicationContext;
BasePageTestCase(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
super.setUp();
servletContext.addInitParameter(BasePage.jstlBundleParam,
MESSAGES);
servletContext.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"classpath*:/applicationContext-resources.xml, " +
"classpath*:/applicationContext-dao.xml, " +
"classpath*:/applicationContext-service.xml," +
"classpath*:/applicationContext.xml" // for modular
archetypes
//"/WEB-INF/applicationContext*.xml"
);
ServletContextListener contextListener = new
ContextLoaderListener();
ServletContextEvent event = new
ServletContextEvent(servletContext);
contextListener.contextInitialized(event);
applicationContext =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
// change the port on the mailSender so it doesn't conflict with an
// existing SMTP server on localhost
JavaMailSenderImpl mailSender = (JavaMailSenderImpl)
applicationContext.getBean("mailSender");
mailSender.setPort(2525);
mailSender.setHost("localhost");
}
protected void tearDown() throws Exception {
super.tearDown();
}
protected Object getManagedBean(String name) {
return FacesUtils.getManagedBean(name);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]