I have a copy of the noejb example that I am modifying.  I've modified it only 
to change package names.  But my ChangePasswordTest is failing.

ChangePasswordTest has this code.  The failure is on the "assert 
outcome==null;" line.

      new Script() {
  | 
  |          ChangePasswordAction changePassword;
  | 
  |          @Override
  |          protected void applyRequestValues() throws Exception
  |          {
  |             Contexts.getSessionContext().set("loggedIn", true);
  |             Contexts.getSessionContext().set("user", new User("Gavin King", 
"foobar", "gavin"));
  |          }
  | 
  |          @Override
  |          protected void updateModelValues() throws Exception
  |          {
  |             User user = (User) Component.getInstance("user", true);
  |             user.setPassword("xxx");
  |             changePassword = (ChangePasswordAction) 
Component.getInstance("changePassword", true);
  |             changePassword.setVerify("xxx");
  |          }
  | 
  |          @Override
  |          protected void invokeApplication()
  |          {
  |             String outcome = changePassword.changePassword();
  |              log.info("Outcome is " + outcome);
  |             assert outcome==null; // fails
  |          }
  | 
  |          @Override
  |          protected void renderResponse()
  |          {
  |             User user = (User) Component.getInstance("user", false);
  |             assert user.getName().equals("Gavin King");
  |             assert user.getUsername().equals("gavin");
  |             assert user.getPassword().equals("xxx");
  |             assert !Manager.instance().isLongRunningConversation();
  |             assert 
Contexts.getSessionContext().get("loggedIn").equals(true);
  | 
  |          }
  | 
  |       }.run();

My question is, why is outcome expected to be null there?  It looks to me like 
the test goes to pains to set up a User object whose password *does* match the 
value of "verify".  And ChangePasswordAction is:

@Name("changePassword")
  | @LoggedIn
  | public class ChangePasswordAction
  | {
  |    
  |    private static final Logger log = 
Logger.getLogger(ChangePasswordAction.class);
  | 
  |    @In @Out @Valid
  |    private User user;
  |    
  |    @In(create=true)
  |    private Session bookingDatabase;
  |    
  |    @In
  |    private FacesContext facesContext;
  |    
  |    private String verify;
  |    
  |    @IfInvalid(outcome=REDISPLAY)
  |    public String changePassword()
  |    {
  |        log.info("user is " + user + " with password " + user.getPassword());
  |       if ( user.getPassword().equals(verify) )
  |       {
  |          log.info("updating password to: " + verify);
  |          user = (User) bookingDatabase.merge(user);
  |          return "main";
  |       }
  |       else 
  |       {
  |          log.info("password not verified");
  |          facesContext.addMessage(null, new FacesMessage("Re-enter new 
password"));
  |          bookingDatabase.refresh(user);
  |          verify=null;
  |          return null;
  |       }
  |    }
  | 
  |    public String cancel()
  |    {
  |       bookingDatabase.refresh(user);
  |       return "main";
  |    }
  | 
  |    public String getVerify()
  |    {
  |       return verify;
  |    }
  | 
  |    public void setVerify(String verify)
  |    {
  |       this.verify = verify;
  |    }
  | 
  | }

Looks to me like if user.getPassword().equals(verify), which it *does* in this 
test, then outcome is -- and SHOULD be -- "main", not null.

And that's what I see in my log:

INFO  20-01 23:17:48,562 (ChangePasswordAction.java:changePassword:38)  -user 
is User(gavin) with password xxx
  | INFO  20-01 23:17:52,281 (ChangePasswordAction.java:changePassword:41)  
-updating password to: xxx
  | INFO  20-01 23:20:54,187 (ChangePasswordTest.java:invokeApplication:51)  
-Outcome is main
  | java.lang.AssertionError
  |     at 
com.robjsoftware.replog.test.ChangePasswordTest$1.invokeApplication(ChangePasswordTest.java:52)

The action looks right to me.  It's the *test* that looks wrong!

What simple detail am I missing?
Thanks,
Rob


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3918807#3918807

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3918807


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to