[ https://issues.apache.org/struts/browse/SHALE-475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43513#action_43513 ]
Chris Keefer commented on SHALE-475: ------------------------------------ I have found that you can manually add beans to the request map. This works for me. Here is an example. public void setUp() throws Exception { super.setUp(); // setup DocRoot for ServletContext calls to getRealPath // or getResourceAsStream File root = new File("WebContent"); servletContext.setDocumentRoot(root); MyBean myBean = new MyBean(); // simulate a managed bean facesContext.getExternalContext() .getRequestMap().put("myBean", myBean); } Hope this help! --Chris > Setup managed bean in JSF 1.2 > ----------------------------- > > Key: SHALE-475 > URL: https://issues.apache.org/struts/browse/SHALE-475 > Project: Shale > Issue Type: Bug > Components: Test > Affects Versions: 1.0.4 > Environment: Java 5, OS X 10.4.10, JSF 1.2 > Reporter: Chris Keefer > > When trying to add a managed bean to the Mock Faces Context a Missing > Resource Exception is thrown. The test class extends AbstractJsfTestCase. The > 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 the 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) > --Chris -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.