The basic SeamTest is working fine, but injection is not working in the class to be tested.
My Test method is as follows:
@Test(groups = {"level.integration"})
public void addAccount() throws Exception {
new FacesRequest("/pages/addaccount.xhtml") {
@Override
protected void updateModelValues() {
AccountDataFromUser atationDataFromUser = (AccountDataFromUser) Component.getInstance("accountDataFromUser");
AddAccount addAccountBean = (AddAccount) Component.getInstance("addAccountBean");
Contexts.getSessionContext().set("accountDataFromUser", accountDataFromUser);
}
@Override
protected void invokeApplication() {
invokeAction("#{addAccountBean.getAvailableLimits}");
Object outcome =
invokeMethod("#{addAccountFEB.onSave}");
//assert outcome != null && outcome.equals("success");
}
@Override
protected void renderResponse() throws Exception {
List<FacesMessage> messages =
FacesMessages.instance().getCurrentMessages();
assert messages.get(0).getSummary().contains("success");
}
}.run();
}
Inside the class addAccountBean, the object accountDataFromUser is supposed to be injected (using @In) and it is being used in getAvailableLimits method.
The problem is that it is not getting injected at all inspite of me calling Contexts.getSessionContext().set("accountDataFromUser", accountDataFromUser);
So accountDataFromUser is null in addAccountBean.getAvailableLimits method which is causing NullPointerException.
I would appreciate any help. I am really stuck here and spent many many hours in this.