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:[email protected]]
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 <[email protected]>
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
[email protected]
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users