Sure thing Remi. The following example fails because the id is null.
Nathan
ACTION
package com.foo.stripes;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
@UrlBinding("/foo/{$event}/{id}")
public class TestAction implements ActionBean {
ActionBeanContext context;
Integer id;
@DefaultHandler
public Resolution bar() {
return null;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Override
public void setContext(ActionBeanContext context) {
this.context = context;
}
@Override
public ActionBeanContext getContext() {
return this.context;
}
}
TEST
package com.foo.stripes;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.stripes.controller.DispatcherServlet;
import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.mock.MockRoundtrip;
import net.sourceforge.stripes.mock.MockServletContext;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class ParameterTestAction {
MockServletContext context;
@Before
public void setup() {
context = new MockServletContext("test");
// Add the Stripes Filter
Map<String,String> filterParams = new HashMap<String,String>();
filterParams.put("ActionResolver.Packages", "com.foo.stripes");
context.addFilter(StripesFilter.class, "StripesFilter",
filterParams);
// Add the Stripes Dispatcher
context.setServlet(DispatcherServlet.class,
"StripesDispatcher", null);
}
@Test
public void testParameter() throws Exception {
final Integer id = 2;
MockRoundtrip trip = new MockRoundtrip(context,
TestAction.class);
trip.setParameter("id", id.toString());
trip.execute();
TestAction action = trip.getActionBean(TestAction.class);
assertEquals(id, action.getId());
}
}
On Wed, Oct 20, 2010 at 2:56 AM, VANKEISBELCK Remi <[email protected]> wrote:
> Haven't looked yet, but the log might be "normal".
>
> Could you post a test case that reproduces your bug ? This way I'll have a
> closer look if you want.
>
> Cheers
>
> Remi
>
> 2010/10/20 Nathan Maves <[email protected]>
>>
>> Just tested this with logging on 1.5.3. It looks like there is an
>> issue with the {$event} binding but I am not sure that is really an
>> issue or not.
>>
>> Let me know if there is anything else I can do on my end to help out.
>>
>> Here is the log for 1.5.3
>>
>> INFO 2010-10-19 21:46:10,991 net.sourceforge.stripes.util.Log.info():
>> Stripes Initialization Complete. Version: 1.5.3, Build: 1.5.3
>> DEBUG 2010-10-19 21:46:11,844
>> net.sourceforge.stripes.util.Log.debug(): LocalePicker selected
>> locale: en_US
>> DEBUG 2010-10-19 21:46:11,844
>> net.sourceforge.stripes.util.Log.debug(): LocalePicker did not pick a
>> character encoding, using default: UTF-8
>> DEBUG 2010-10-19 21:46:11,848
>> net.sourceforge.stripes.util.Log.debug(): Matched
>> /admin/product/{$event}/{product.id} to
>> /admin/product/{$event}/{product.id}
>> INFO 2010-10-19 21:46:11,858 net.sourceforge.stripes.util.Log.info():
>> Expression validation will be performed using:
>> net.sourceforge.stripes.validation.expression.Jsp20ExpressionExecutor
>> DEBUG 2010-10-19 21:46:11,859
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage RequestInit
>> DEBUG 2010-10-19 21:46:11,862
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage ActionBeanResolution
>> DEBUG 2010-10-19 21:46:11,863
>> net.sourceforge.stripes.util.Log.debug(): Matched
>> /admin/product/{$event}/{product.id} to
>> /admin/product/{$event}/{product.id}
>> DEBUG 2010-10-19 21:46:11,866
>> net.sourceforge.stripes.util.Log.debug(): Matched
>> /admin/product/{$event}/{product.id} to
>> /admin/product/{$event}/{product.id}
>> DEBUG 2010-10-19 21:46:11,871
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage HandlerResolution
>> DEBUG 2010-10-19 21:46:11,874
>> net.sourceforge.stripes.util.Log.debug(): Resolved event: edit; will
>> invoke: ProductEditAction.edit()
>> DEBUG 2010-10-19 21:46:11,876
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage BindingAndValidation
>> DEBUG 2010-10-19 21:46:11,961
>> net.sourceforge.stripes.util.Log.debug(): Loaded validations for
>> ActionBean ProductEditAction:
>> product.title->ValidationMetadata{required=true},
>> product.sku->ValidationMetadata{required=true},
>> product.languageId->ValidationMetadata{required=true}
>> DEBUG 2010-10-19 21:46:11,963
>> net.sourceforge.stripes.util.Log.debug(): Running required field
>> validation on bean class
>> com.dreamscape.stripes.admin.products.ProductEditAction
>> DEBUG 2010-10-19 21:46:11,973
>> net.sourceforge.stripes.util.Log.debug(): Could not bind property with
>> name [{$event}] to bean of type: ProductEditAction : Bean class
>> com.dreamscape.stripes.admin.products.ProductEditAction does not
>> contain a property called '{$event}'. As a result the following
>> expression could not be evaluated: {$event}
>> DEBUG 2010-10-19 21:46:11,982
>> net.sourceforge.stripes.util.Log.debug(): Creating
>> net.sourceforge.stripes.controller.BindingPolicyManager for class
>> com.dreamscape.stripes.admin.products.ProductEditAction with default
>> policy null
>> DEBUG 2010-10-19 21:46:11,987
>> net.sourceforge.stripes.util.Log.debug(): Translated globs [] to regex
>> DEBUG 2010-10-19 21:46:11,987
>> net.sourceforge.stripes.util.Log.debug(): Translated globs [] to regex
>> DEBUG 2010-10-19 21:46:11,989
>> net.sourceforge.stripes.util.Log.debug(): Translated globs
>> [product.title, product.sku, product.languageId] to regex
>> product\.title|product\.sku|product\.languageId
>> DEBUG 2010-10-19 21:46:11,991
>> net.sourceforge.stripes.util.Log.debug(): Converting 2 value(s) using
>> converter net.sourceforge.stripes.validation.IntegerTypeConverter
>> DEBUG 2010-10-19 21:46:11,996
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage CustomValidation
>> DEBUG 2010-10-19 21:46:11,999
>> net.sourceforge.stripes.util.Log.debug(): Looking up localized field
>> name with messageKey: product.id
>> DEBUG 2010-10-19 21:46:12,005
>> net.sourceforge.stripes.util.Log.debug(): The following validation
>> errors need to be fixed:
>> -> [product.id] invalid number
>> DEBUG 2010-10-19 21:46:12,008
>> net.sourceforge.stripes.util.Log.debug(): Transitioning to lifecycle
>> stage ResolutionExecution
>> DEBUG 2010-10-19 21:46:12,009
>> net.sourceforge.stripes.util.Log.debug(): Looking for HttpCache on
>> com.dreamscape.stripes.admin.products.ProductEditAction.edit()
>> DEBUG 2010-10-19 21:46:12,012
>> net.sourceforge.stripes.util.Log.debug(): No URL binding matches
>> _default_source_page_
>> DEBUG 2010-10-19 21:46:12,013
>> net.sourceforge.stripes.util.Log.debug(): No URL binding matches
>> _default_source_page_
>>
>> On Tue, Oct 19, 2010 at 2:19 AM, VANKEISBELCK Remi <[email protected]> wrote:
>> > Hi Nathan,
>> >
>> > Try turning Stripes logs to debug and see what happens. The binding code
>> > is
>> > pretty verbose.
>> >
>> > I've been using clean URLs in mock trips without any problem so far.
>> >
>> > Cheers
>> >
>> > Remi
>> >
>> > 2010/10/19 Nathan Maves <[email protected]>
>> >>
>> >> Ah the tricky part is that these are no error messages nor
>> >> exceptions. Just unit tests failing when we upgrade stripes.
>> >>
>> >> This is because the url binding variables are not getting bound in the
>> >> MockRoundTrip properly (at all).
>> >>
>> >> One thing I don't think I tested is removing the {$event} from the
>> >> binding.
>> >>
>> >> @UrlBinding("/admin/product/{$event}/{product.id}")
>> >>
>> >>
>> >> On Mon, Oct 18, 2010 at 7:45 PM, Nikolaos Giannopoulos
>> >> <[email protected]> wrote:
>> >> > Nathan,
>> >> >
>> >> > We have limited test cases for our Action Beans at this time. So far
>> >> > no
>> >> > issues.
>> >> >
>> >> > Could you be more specific about the error that is being produced.
>> >> >
>> >> > --Nikolaos
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > Nathan Maves wrote:
>> >> >> Is there anyone else out here using UrlBinding with MockRoundTrip?
>> >> >> This is killing me that we can upgrade to the latest Stripes
>> >> >> codebase.
>> >> >>
>> >> >> Nathan
>> >> >>
>> >> >> On Wed, Oct 13, 2010 at 11:32 AM, Nathan Maves
>> >> >> <[email protected]>
>> >> >> wrote:
>> >> >>
>> >> >>> We have multiple test cases where we are using UrlBinding with 1.5
>> >> >>> and
>> >> >>> everything works perfect.
>> >> >>>
>> >> >>> Here is an example of one of our bindings
>> >> >>>
>> >> >>> @UrlBinding("/admin/product/{$event}/{product.id}")
>> >> >>>
>> >> >>> All versions (1.5.1, 1.5.2, 1.5.3) work fine outside of the test
>> >> >>> fixture. It is only within a test using the MockRoundTrip where we
>> >> >>> get the error. The error is a validation error where it claims to
>> >> >>> have a conversion issue where the replacement parts are ["Product
>> >> >>> Id",
>> >> >>> "{product.id}"]. We get this when passing in a parameter or not.
>> >> >>>
>> >> >>> I did find the following change from 1.5 to 1.5.1 that might have
>> >> >>> something to do with it.
>> >> >>>
>> >> >>> http://www.stripesframework.org/jira/browse/STS-592
>> >> >>>
>> >> >>>
>> >> >>> Nathan
>> >> >>>
>> >> >>>
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------------------------------------------------
>> >> > Download new Adobe(R) Flash(R) Builder(TM) 4
>> >> > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> >> > Flex(R) Builder(TM)) enable the development of rich applications that
>> >> > run
>> >> > across multiple browsers and platforms. Download your free trials
>> >> > today!
>> >> > http://p.sf.net/sfu/adobe-dev2dev
>> >> > _______________________________________________
>> >> > Stripes-users mailing list
>> >> > [email protected]
>> >> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >> >
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Download new Adobe(R) Flash(R) Builder(TM) 4
>> >> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> >> Flex(R) Builder(TM)) enable the development of rich applications that
>> >> run
>> >> across multiple browsers and platforms. Download your free trials
>> >> today!
>> >> http://p.sf.net/sfu/adobe-dev2dev
>> >> _______________________________________________
>> >> Stripes-users mailing list
>> >> [email protected]
>> >> https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Download new Adobe(R) Flash(R) Builder(TM) 4
>> > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> > Flex(R) Builder(TM)) enable the development of rich applications that
>> > run
>> > across multiple browsers and platforms. Download your free trials today!
>> > http://p.sf.net/sfu/adobe-dev2dev
>> > _______________________________________________
>> > Stripes-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >
>> >
>
>
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users