4 Replies Latest reply on Sep 14, 2007 5:28 AM by Alexander Mashtakov

    SeamTest.FacesRequest: question

    Alexander Mashtakov Newbie

      Hi All,

      While writting integration tests I noticed the following behavour
      SeamTest mock. In order to update user's profile I have to log-in
      first. So, we need two requests:

      1)
      new FacesRequest("/login.xhtml") {
      @Override
      protected void updateModelValues() throws Exception {
      setValue("#{identity.username}", AC_LOGIN);
      setValue("#{identity.password}", AC_PASSWORD);
      }
      @Override
      protected void invokeApplication() throws Exception {
      assert invokeMethod("#{identity.login}").equals("loggedIn");
      assert (Boolean) getValue("#{identity.loggedIn}");
      }
      }.run();

      2)

      new FacesRequest("/profile.xhtml") {
      @Override
      protected void invokeApplication() {
      UserProfile up = (UserProfile) getInstance("pcUserProfile");
      up.beginEdit();
      assert (Boolean) getValue("#{identity.loggedIn}");
      }
      @Override
      protected void renderResponse() {
      assert isLongRunningConversation();
      }
      }.run();


      All works fine in case in both requests are in the same method of
      test class.

      In case of I put each of them in separate methods (for ex: m1 and m2),
      assert (Boolean) getValue("#{identity.loggedIn}") of m2 fails.

      Tried to figure out the reason but with no success (in both cases
      FacesContext.getCurrentInstance() points to different objects).

      Could you please clarify why does this happen ?

      Thank you in advance,
      /Alexander