I meant to add the paragraph that I sent, but it's more clear to add a unit
test. (tested with 2.3.1.4.3)
What I said in my previous email is that the Restful2ActionMapper cannot
determine which action to call, just
from the uri, it also needs the http method that should be passed in the
request mock.
note for the existing documentation : the id in "<param name="id">{0}</
param>" should change to "<param name="id">{1}</param>"
public class MovieActionTest extends StrutsJUnit4TestCase<MovieActionTest>{
@Before
public void setUp() throws Exception {
//assumes Basic authentication
super.setUp();
String credentials = "username:password";
request.addHeader("authorization", "BASIC " +
Base64.encodeBase64String(credentials.getBytes()));
}
@Test
public void testIndex() throws Exception {
request.setMethod("get"); //Http method should be set
ActionProxy proxy = getActionProxy("/rest/movie/");
proxy.setExecuteResult(false);
String result = proxy.execute();
//assertions ...
}
@Test
public void testView() throws Exception {
request.setMethod("get"); //Http method should be set
ActionProxy proxy = getActionProxy("/rest/movie/1");
MovieAction movieAction = MovieAction.class.cast(proxy.getAction());
proxy.setExecuteResult(false);
String result = proxy.execute();
//assertions ...
assertEquals("1", movieAction.getId());
}
}
Thanks,
Antonios
On 14 June 2013 12:36, Lukasz Lenart <[email protected]> wrote:
> You mean to add section about testing? Maybe it would better to show
> sample code with sample unittest, could you post something like that
> here?
>
>
> Thanks in advance!
> --
> Ćukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> 2013/6/14 Antonios Gkogkakis <[email protected]>:
> > Hi all,
> >
> > I've made a documentation contribution on the Restful2ActionMapper a few
> > months ago,
> >
> > https://cwiki.apache.org/WW/restfulactionmapper.html
> >
> > Could someone that has access to the wiki (Lukasz :D) append that, in
> order
> > to test
> > an action using the Restful2ActionMapper with StrutsJUnit4TestCase
> someone
> > has to
> > set the http method on the protected mock http object, e.g., request.
> > setMethod("get")
> >
> > It makes sense now, but it took me a couple of hours to figure it out :D
> >
> > Thanks,
> > Antonios
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>