Probably not the best solution but this piece of code has been here for a very 
long time:

      Assert.assertEquals(Patient.class, 
getRedirectActionClass(trip.getDestination()));


      protected Class<? extends ActionBean> getRedirectActionClass(String 
destination) {
            int queryStringPos = destination.indexOf("?");
            return StripesFilter.getConfiguration().getActionResolver()
                        .getActionBeanType(
                                    0 <= queryStringPos ? 
destination.substring(0,
                                                queryStringPos) : destination);
      }




From: Levi Hoogenberg [mailto:levihoogenb...@gmail.com]
Sent: Tuesday, December 15, 2009 12:32 AM
To: Stripes Users List
Subject: Re: [Stripes-users] Best way to test redirects with url bindings

I figured you'd come up with this (or with extracting a constant into a static 
Destinations class). Internally, Stripes uses a UrlBindingFactory (IIRC) to 
interpolate the URL parameters; you could use that class in your unit tests 
too. My strategy is to simply use strings - if a binding changes (whcich rarely 
occurs IME), I'll fix the unit tests.

Op 15 dec 2009 om 01:35 heeft Nathan Maves 
<nathan.ma...@gmail.com<mailto:nathan.ma...@gmail.com>> het volgende 
geschreven:\
Good call and this works perfect for simple UrlBinding.  I just ran into this 
binding

@UrlBinding("/account/admin/branches/{$event}/{branch.id<http://branch.id>}")

Guess I am looking for a best practice on how most people unit test their 
redirect actions in stripes.

Nathan
On Mon, Dec 14, 2009 at 4:43 PM, Levi Hoogenberg 
<levihoogenb...@gmail.com<mailto:levihoogenb...@gmail.com>> wrote:
Something like SettingsMenuAction.class.getAnnotation
(UrlBinding.class).value() should do the trick.

  Levi

Op 14 dec 2009 om 23:49 heeft Nathan Maves 
<nathan.ma...@gmail.com<mailto:nathan.ma...@gmail.com>>
het volgende geschreven:\

> right now I have an action like....
>
> @UrlBinding("/settings")
> public class SettingsMenuAction extends SettingsTabAction {
> ...
> }
>
> a second action redirects to the action via....
>
>       public Resolution cancel() {
>               return new RedirectResolution(SettingsMenuAction.class);
>       }
>
> now in the unit test of the action that makes the redirect I can run
> the following fine.
>
>       @Test
>       public void cancel() throws Exception {
>               trip.execute("cancel");
>
>               assertEquals("/settings", trip.getDestination());
>       }
>
> The only issue I have is with the static "/settings" in the test
> assertion.  Is there anyway to get that binding from the action class?
>
> Nathan
> ---
> ---
> ---
> ---------------------------------------------------------------------
> Return on Information:
> Google Enterprise Search pays you back
> Get the facts.
> http://p.sf.net/sfu/google-dev2dev
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to