Sebastien,

You say:
Stripersist is supposed to do all the job for me to retreived and modify the 
user.
Clearly there is something missing in this picture. By default Stripes creates a new instance of an ActionBean on each invocation yet you are only passing in the "id" and then your update resolution is merely doing a save.

Do you have a custom converter or something that is loading the object by "id" and making it available as the user attribute?

Please simply post your complete UserAdminBean code and any custom converter that you may have.

I can't help you if I don't see the full picture.

--Nikolaos



Sebastien Belin wrote:
Hi,

@Frank: I don't think I use any "Open Session/EntityManager in View" filter unless Stripersist/Stripes implements one.
The only filter 'm using are ShiroFilter for security and StripesFilter.
But I'm going to investigate this a bit more.

@Nikolaos.
Thanks for all your effort to help me.
I do understand what you  mean about transaction and detached object could not 
being persisted.
If I do a merge before saving or deleting an existing object my tests work with 
great success indeed.

I want to clarify something in my test though, I never give a detached instance 
to the mockRoundtrip. I just give the id and the name as parameters.
Stripersist is supposed to do all the job for me to retreived and modify the 
user.
The update method does only the saving/commit.

The getUser() method is really simple too:

public class UserAdminBean {
  private User user;
  ...
  public User getUser() {
    return user;
  }
  ...
  public Resolution update() {
    getDao().save(getUser());
    getDao().commit();
    return new RedirectResolution(this.getClass(), "view").addParameter("user", 
getUser());
} ...
}

@Test
public void testUpdate() throws Exception {
  User user = createUser();
  MockRoundtrip mockRoundtrip = new MockRoundtrip(getServletContext(), 
UserActionBean.class);
  mockRoundtrip.addParameter("user", String.valueOf(user.getId()));
  mockRoundtrip.addParameter("user.name", "newName");
  mockRoundtrip.execute("update");
  RedirectResolution redirectResolution = new RedirectResolution(UserActionBean.class, 
"view").addParameter("user", user);
  String redirectUrl = redirectResolution.getUrl(Locale.getDefault());
  verifyDestination(mockRoundtrip, redirectUrl);
  assertUserUpdated(user);
}


Thanks,

Sebastien

-----Original Message-----
From: Frank Pavageau [mailto:frank.pavag...@gmail.com] Sent: 08 April 2011 16:38
To: Stripes Users List
Subject: Re: [Stripes-users] Stripes testing with MockServletContext and 
Stripersist

On Fri, Apr 8, 2011 at 4:54 PM, Sebastien Belin <sebastien.be...@adaptris.com> 
wrote:
I indeed don't do any merge to reattached the user object as I though it's not really efficient and it was not needed as it was working in not testing mode.

I also didn't think that with Stripersist the object was detached when loaded in the ActionBean.

Aren't you by any chance using in your webapp a filter to implement the "Open 
Session/EntityManager in View" pattern ? Like the one from Spring (OpenSessionInViewFilter) ? 
That would be the reason why your entities are not detached in "not testing" mode.

Frank

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming smartphone on the nation's most 
reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Nikolaos Giannopoulos
Director, Information Technology
BrightMinds Software Inc.
e. nikol...@brightminds.org
w. www.brightminds.org
t. 1.613.822.1700
c. 1.613.797.0036
f. 1.613.822.1915

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to