Stripes

MockRoundtrip doesn't work with clean url:s

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.5.1
  • Fix Version/s: None
  • Component/s: ActionBean Dispatching
  • Labels:
    None

Description

I'm having some problems after upgrading from Stripes 1.5 to Stripes 1.5.1.

I have a simple ActionBean with a property called path. I try to set this property using @UrlBinding("/test/{path}.html") but this only works half way.

Calling this action using /test/some/path.html will call the correct action and set the path property to "some/path". This behavior is expected.
Calling the same action in a test case using MockRoundtrip however will set the path to "{path}". This behavior is not expected.

After debugging the Stripes code I traced the problem back to STS-616. It seems that the MergedParameterMap contains the following array ["{path}", "some/path"] when it's created from a MockRoundtrip but not during normal execution.

I'll attach a test case for this and hope for a fix or a workaround. Meanwhile I'll have to go back to 1.5.

  1. TestActionBean.java
    27/Aug/09 4:34 AM
    0.8 kB
    Joakim Kemeny
  2. TestActionBeanTest.java
    27/Aug/09 4:34 AM
    1 kB
    Joakim Kemeny

Activity

Hide
Joakim Kemeny added a comment - 27/Aug/09 4:34 AM

TestCase to reproduce this problem.

Show
Joakim Kemeny added a comment - 27/Aug/09 4:34 AM TestCase to reproduce this problem.
Hide
Joakim Kemeny added a comment - 27/Aug/09 4:34 AM

TestCase to reproduce this problem.

Show
Joakim Kemeny added a comment - 27/Aug/09 4:34 AM TestCase to reproduce this problem.
Hide
Karen added a comment - 03/Sep/09 1:20 PM

I have the same problem here.

Runtime the action bean works great. But when doing a MockRoundTrip on the actionBean that has a URLBinding with parameters, it always binds "{variable-name}" instead of the actual parameter value (even if no parameters are added to the MockRoundTrip and it should not bind anything).

Unfortunately I did not find a work around either and am unable to unit test my actionbeans now.

Show
Karen added a comment - 03/Sep/09 1:20 PM I have the same problem here. Runtime the action bean works great. But when doing a MockRoundTrip on the actionBean that has a URLBinding with parameters, it always binds "{variable-name}" instead of the actual parameter value (even if no parameters are added to the MockRoundTrip and it should not bind anything). Unfortunately I did not find a work around either and am unable to unit test my actionbeans now.
Hide
Karen added a comment - 02/Nov/09 10:51 AM

Joakim,

I had the same problem. The solution is to use the MockRoundTrip constructor that includes an URL. In you're case you could try something like:

MockRoundtrip trip = new MockRoundtrip(context, "/test/path");
trip.execute();
assertNull(trip.getForwardUrl());
assertEquals("path", trip.getActionBean(TestActionBean.class).getPath());

Show
Karen added a comment - 02/Nov/09 10:51 AM Joakim, I had the same problem. The solution is to use the MockRoundTrip constructor that includes an URL. In you're case you could try something like: MockRoundtrip trip = new MockRoundtrip(context, "/test/path"); trip.execute(); assertNull(trip.getForwardUrl()); assertEquals("path", trip.getActionBean(TestActionBean.class).getPath());
Hide
Karen added a comment - 02/Nov/09 10:52 AM

This issue seems fixed, I propose to close it.

Show
Karen added a comment - 02/Nov/09 10:52 AM This issue seems fixed, I propose to close it.
Hide
Joakim Kemeny added a comment - 06/Nov/09 10:07 AM

Thank you Karen. This worked for me as well.
It's still strange that the behaviour changed but I have no problem marking this issue as Won't fix provided this workaround.

Show
Joakim Kemeny added a comment - 06/Nov/09 10:07 AM Thank you Karen. This worked for me as well. It's still strange that the behaviour changed but I have no problem marking this issue as Won't fix provided this workaround.
Hide
Ben Gunter added a comment - 19/May/10 9:24 AM

The comments indicate the problem is resolved so I'm closing as fixed.

Show
Ben Gunter added a comment - 19/May/10 9:24 AM The comments indicate the problem is resolved so I'm closing as fixed.
Hide
Janne Jalkanen added a comment - 23/Sep/10 7:14 AM

Still occurring on 1.5.x, but the workaround does work.

Show
Janne Jalkanen added a comment - 23/Sep/10 7:14 AM Still occurring on 1.5.x, but the workaround does work.

People

Vote (0)
Watch (1)

Dates

  • Created:
    27/Aug/09 4:33 AM
    Updated:
    04/Jan/11 1:45 PM
    Resolved:
    19/May/10 9:24 AM