2 Replies Latest reply on Feb 5, 2009 6:19 AM by vivek b

    Injection is not working in the class to be tested.

    vivek b Newbie
      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") {

         protected void updateModelValues() {
          AccountDataFromUser atationDataFromUser = (AccountDataFromUser) Component.getInstance("accountDataFromUser");
          AddAccount addAccountBean = (AddAccount) Component.getInstance("addAccountBean");
          Contexts.getSessionContext().set("accountDataFromUser", accountDataFromUser);

         protected void invokeApplication() {
          Object outcome =
          //assert outcome != null && outcome.equals("success");

         protected void renderResponse() throws Exception {
          List<FacesMessage> messages =
          assert messages.get(0).getSummary().contains("success");

      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.