Thanks Matt.

With that, I can use the new ConfigParser helper class, parse and load the faces-config.xml, and _still_ get a NPE in the test class -- the FacesUtils.getManagedBean() function still returns null for the passwordHint bean as it was doing even before loading the faces-context.xml. Boo! I do note that getManagedBean()'s implementation uses the deprecated ValueBinding class. However "deprecated" isn't supposed to mean "no longer functional". So it may not be the cause of my travails.

 public static Object getManagedBean(String beanName) {
        Object o =

getValueBinding(getJsfEl(beanName)).getValue(FacesContext.getCurrentInstance());

        return o;
    }

Ideas?
Steve


On 5/29/2007 6:36 PM, Matt Raible wrote:
There's a snapshot repository for Apache you could add to your pom.xml:

http://people.apache.org/maven-snapshot-repository/

It looks like there's a 1.1.0-SNAPSHOT available from April 21st.

It looks like the bug you're referring to was fixed in January, so I
expect it'd be available in this snapshot.

Matt

On 5/29/07, Steve Tynor <[EMAIL PROTECTED]> wrote:
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]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to