"session",
null,
null,
list,
null);
BeanManager beanManager =
ApplicationAssociate.getCurrentInstance().getBeanManager();
beanManager.register(bean);
//testing with a property set
assertNotNull(testBean = (TestBean) beanManager.create(beanName,
getFacesContext()));
//make sure bean instantiated properly. Get property back from bean.
assertTrue(testBean.getOne().equals("one"));
//testing with:
// valueref in request scope
// managed bean in application scope
getFacesContext().getExternalContext().getApplicationMap()
.remove("TestRefBean");
getFacesContext().getExternalContext().getRequestMap().put(
"TestRefBean", testBean);
bean = new ManagedBeanInfo(beanName,
beanName,
"application",
null,
null,
list,
null);
beanManager.register(bean);
exceptionThrown = false;
try {
//testing with a property set
beanManager.create(beanName, getFacesContext());
fail("Should have thrown FacesException");
} catch (FacesException ex) {
exceptionThrown = true;
}
assertTrue(exceptionThrown);
//cleanup
getFacesContext().getExternalContext().getRequestMap().remove(
"TestRefBean");
//testing with:
// valueref in session scope
// managed bean in no scope
getFacesContext().getExternalContext().getSessionMap().put(
"TestRefBean", testBean);
bean = new ManagedBeanInfo(beanName,
beanName,
"none",
null,
null,
list,
null);
beanManager.register(bean);
exceptionThrown = false;
try {
beanManager.create(beanName, getFacesContext());
fail("Should have thrown FacesException");
} catch (FacesException ex) {
exceptionThrown = true;
}
assertTrue(exceptionThrown);