Hi Daryl,

As you said, it might get tricky to test the response like this.
AJAX-based testing is outside the scope of the Stripes mock
framework; however, I'd recommend HtmlUnit[1] and do higher-level
AJAX/JavaScript testing, i.e. test for the ultimate result on the
page that you want to verify. It works great for such things. For
example, you can verify such behavior as the classic "selecting
an item from a select box populates another select box with AJAX",
even if the select box is not present on the initial page.

Cheers,
Freddy

[1]:http://htmlunit.sourceforge.net

On Mon, 31 May 2010 14:30:35 -0700, "Daryl Handley"
<darylhand...@gmail.com> said:
> Is there a standard way to do this based on what is returned from the 
> MockRoundtrip ?
> 
> For example,  I have an AJAX based login. If my test code looks like
> this.
> 
>      trip = new MockRoundtrip(servletContext, 
> AjaxLoginOrMenuActionBean.class);
>      trip.execute("login");
>      AjaxLoginOrMenuActionBean actionBean = 
> trip.getActionBean(AjaxLoginOrMenuActionBean.class);
> 
> 
> What can I do from here to test the response I get ?
> 
> 
> The body of the response (which I can get 
> trip.getResponse().getOutputString())  will look something like this;
> 
> var _sj_root_2094544448;
> var _sj_1490854893 = {"error":"The username or password was incorrect. 
> Please try again."};
> _sj_root_2094544448 = _sj_1490854893;
> _sj_root_2094544448;
> 
> So I guess I would need to somehow eval this and get then read the error 
> back and do some assertions on it, but not sure of an easy way to do it. 
> Perhaps Rhino has something for this ?
> 
> Thanks,
> Daryl
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to