Hello,

I am trying to add a managed bean to the Mock Faces Context that will be used in my unit test. My test class extends AbstractJsfTestCase. My setUp method is the following:

public void setUp() throws Exception {
    super.setUp();

    // add managed bean
    _factory = application.getExpressionFactory();
    _elContext = MockFacesContext.getCurrentInstance().getELContext();
    ValueExpression expression =
_factory.createValueExpression(_elContext, "#{leftNav}", LeftNav.class); MockServletContext context = (MockServletContext) session.getServletContext();
    context.setDocumentRoot(new File(DOC_ROOT));
    expression.setValue(_elContext, new LeftNav());
}

The last line throws a MissingResourceException.

java.util.MissingResourceException: Can't find bundle for base name leftNav, locale en_US at java.util.ResourceBundle.throwMissingResourceException (ResourceBundle.java:836) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java: 805)
      at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
at org.apache.shale.test.mock.MockApplication12.getResourceBundle (MockApplication12.java:261) at org.apache.shale.test.el.FacesResourceBundleELResolver.setValue (FacesResourceBundleELResolver.java:202) at javax.el.CompositeELResolver.setValue (CompositeELResolver.java:283) at org.apache.shale.test.el.MockValueExpression.setValue (MockValueExpression.java:248)

Im not exactly sure what resource bundle the Resolver is looking for. Perhaps the faces-config.xml? Is this the correct way to add a managed bean to the faces context?

Best,
--Chris

Reply via email to