Revision: 1314 http://stripes.svn.sourceforge.net/stripes/?rev=1314&view=rev Author: bengunter Date: 2010-11-10 15:49:08 +0000 (Wed, 10 Nov 2010)
Log Message: ----------- Applied fix for STS-731 from 1.5.x branch Modified Paths: -------------- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java trunk/tests/src/net/sourceforge/stripes/controller/UrlBindingFactoryTests.java Modified: trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java =================================================================== --- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 2010-11-10 15:47:03 UTC (rev 1313) +++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 2010-11-10 15:49:08 UTC (rev 1314) @@ -231,17 +231,17 @@ if (prototype == null) return null; - // ignore trailing slashes in the URI + // check for literal suffix in prototype and ignore it if found int length = uri.length(); - while (length > 0 && uri.charAt(length - 1) == '/') - --length; - - // check for literal suffix in prototype and ignore it if found String suffix = prototype.getSuffix(); if (suffix != null && uri.endsWith(suffix)) { length -= suffix.length(); } + // ignore trailing slashes in the URI + while (length > 0 && uri.charAt(length - 1) == '/') + --length; + // extract the request parameters and add to new binding object ArrayList<Object> components = new ArrayList<Object>(prototype.getComponents().size()); int index = prototype.getPath().length(); Modified: trunk/tests/src/net/sourceforge/stripes/controller/UrlBindingFactoryTests.java =================================================================== --- trunk/tests/src/net/sourceforge/stripes/controller/UrlBindingFactoryTests.java 2010-11-10 15:47:03 UTC (rev 1313) +++ trunk/tests/src/net/sourceforge/stripes/controller/UrlBindingFactoryTests.java 2010-11-10 15:49:08 UTC (rev 1314) @@ -1,5 +1,9 @@ package net.sourceforge.stripes.controller; +import static java.lang.String.format; + +import java.util.List; + import net.sourceforge.stripes.action.ActionBean; import net.sourceforge.stripes.action.ActionBeanContext; import net.sourceforge.stripes.config.DontAutoLoad; @@ -98,6 +102,13 @@ public static class SuffixActionBean1 extends BaseActionBean {} @DontAutoLoad @net.sourceforge.stripes.action.UrlBinding("/suffix/{a}/{b}/{c}/{d}.action") public static class SuffixActionBean2 extends BaseActionBean {} + + @DontAutoLoad @net.sourceforge.stripes.action.UrlBinding("/sts731/{a}/") + public static class STS731ActionBean1 extends BaseActionBean {} + @DontAutoLoad @net.sourceforge.stripes.action.UrlBinding("/sts731/{a}/foo/") + public static class STS731ActionBean2 extends BaseActionBean {} + @DontAutoLoad @net.sourceforge.stripes.action.UrlBinding("/sts731/{a}/bar/") + public static class STS731ActionBean3 extends BaseActionBean {} private static final Log log = Log.getInstance(UrlBindingFactoryTests.class); private static UrlBindingFactory urlBindingFactory; @@ -110,7 +121,9 @@ FooActionBean.class, FooActionBean1.class, FooActionBean2.class, FooActionBean3.class, FooActionBean4.class, FooActionBean5.class, FooActionBean6.class, FooActionBean7.class, FooActionBean8.class, - SuffixActionBean1.class, SuffixActionBean2.class }; + SuffixActionBean1.class, SuffixActionBean2.class, + STS731ActionBean1.class, STS731ActionBean2.class, STS731ActionBean3.class + }; UrlBindingFactory factory = new UrlBindingFactory(); for (Class<? extends ActionBean> clazz : classes) { @@ -121,11 +134,12 @@ urlBindingFactory = factory; } - private void checkBinding(String uri, Class<? extends ActionBean> expected) { + private List<UrlBindingParameter> checkBinding(String uri, Class<? extends ActionBean> expected) { log.debug("Checking that ", uri, " maps to ", expected); UrlBinding binding = urlBindingFactory.getBinding(uri); - Assert.assertNotNull(binding); + Assert.assertNotNull(binding, "The uri \"" + uri + "\" matched nothing"); Assert.assertSame(binding.getBeanType(), expected); + return binding.getParameters(); } @Test(groups = "fast") @@ -250,6 +264,17 @@ checkBinding("/foo/goo/1", FooActionBean8.class); checkBinding("/foo/goo/1/", FooActionBean8.class); checkBinding("/foo/goo/1/2", FooActionBean8.class); + + // Suffixes, as reported in STS-731 + for (String value : new String[] { "really-long", "long", "XX", "X" }) { + List<UrlBindingParameter> param; + param = checkBinding(format("/sts731/%s/", value), STS731ActionBean1.class); + Assert.assertEquals(param.get(0).getValue(), value); + param = checkBinding(format("/sts731/%s/foo/", value), STS731ActionBean2.class); + Assert.assertEquals(param.get(0).getValue(), value); + param = checkBinding(format("/sts731/%s/bar/", value), STS731ActionBean3.class); + Assert.assertEquals(param.get(0).getValue(), value); + } } @Test(groups = "fast") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev _______________________________________________ Stripes-development mailing list Stripes-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-development