You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kevin Lin <ke...@gmail.com> on 2011/11/29 03:44:23 UTC

[T5.3] Bug PageTester

Hi,

I was running a web test using the latest source code from testify on a
T5.3 application. And I get the following exception for any tests that
contains a request/event:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
 at java.lang.String.substring(String.java:1937)
at java.lang.String.substring(String.java:1904)
 at
org.apache.tapestry5.test.PageTester.setupRequestFromURI(PageTester.java:345)
at
org.apache.tapestry5.test.PageTester.setupRequestFromLink(PageTester.java:331)
 at
org.apache.tapestry5.test.PageTester.runComponentEventRequest(PageTester.java:313)
at
org.apache.tapestry5.test.PageTester.clickLinkAndReturnResponse(PageTester.java:264)
 ...

At bit digging through the code shows that there is mostly a coding bug
in org.apache.tapestry5.test.PageTester#setupRequestFromURI()
 (PageTester.java:345):
--------------------
    private void setupRequestFromURI(String URI)
    {
        String linkPath = stripContextFromPath(URI);
        int comma = linkPath.indexOf('?');
        String path = comma < 0 ? linkPath : linkPath.substring(0, comma);
        request.clear().setPath(path);
        if (comma > 0)
            decodeParametersIntoRequest(path.substring(comma + 1));
    }
--------------------

The *path* variable is the URL path with the event parameters (?xxx)
stripped, trying to substring it again cause the IndexOutOfBounds
exception. The correct variable to pass should instead be: *linkPath*. A
comparison with the same class file confirms my findings (see attached).

My current fix is monkey-patch the PageTester class file. Hopefully this
will be fixed in next release of T53.

Regards,
Kevin Lin

Re: [T5.3] Bug PageTester

Posted by Kevin Lin <ke...@gmail.com>.
Move to TAP5: https://issues.apache.org/jira/browse/TAP5-1770

On Thu, Dec 1, 2011 at 9:52 AM, Kevin Lin <ke...@gmail.com> wrote:

> Thanks Josh. Defect raised in JIRA:
> TAPESTRY-2785 - [T5.3] - PageTester causes StringIndexOutOfBoundsException
> for any page request path with query parameter<https://issues.apache.org/jira/browse/TAPESTRY-2785>
>
> On Tue, Nov 29, 2011 at 10:49 AM, Josh Canfield <jo...@gmail.com>wrote:
>
>> query parameter
>
>
>

Re: [T5.3] Bug PageTester

Posted by Kevin Lin <ke...@gmail.com>.
Thanks Josh. Defect raised in JIRA:
TAPESTRY-2785 - [T5.3] - PageTester causes StringIndexOutOfBoundsException
for any page request path with query
parameter<https://issues.apache.org/jira/browse/TAPESTRY-2785>

On Tue, Nov 29, 2011 at 10:49 AM, Josh Canfield <jo...@gmail.com>wrote:

> query parameter

Re: [T5.3] Bug PageTester

Posted by Josh Canfield <jo...@gmail.com>.
> My current fix is monkey-patch the PageTester class file. Hopefully this
> will be fixed in next release of T53.

It's unlikely to be fixed unless you file a defect in Jira. :)

It's curious that none of the internal tests include a query parameter
that would have caught this.

Josh

On Mon, Nov 28, 2011 at 6:44 PM, Kevin Lin <ke...@gmail.com> wrote:
> Hi,
> I was running a web test using the latest source code from testify on a T5.3
> application. And I get the following exception for any tests that contains a
> request/event:
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(String.java:1937)
> at java.lang.String.substring(String.java:1904)
> at
> org.apache.tapestry5.test.PageTester.setupRequestFromURI(PageTester.java:345)
> at
> org.apache.tapestry5.test.PageTester.setupRequestFromLink(PageTester.java:331)
> at
> org.apache.tapestry5.test.PageTester.runComponentEventRequest(PageTester.java:313)
> at
> org.apache.tapestry5.test.PageTester.clickLinkAndReturnResponse(PageTester.java:264)
> ...
> At bit digging through the code shows that there is mostly a coding bug
> in org.apache.tapestry5.test.PageTester#setupRequestFromURI()
>  (PageTester.java:345):
> --------------------
>     private void setupRequestFromURI(String URI)
>     {
>         String linkPath = stripContextFromPath(URI);
>         int comma = linkPath.indexOf('?');
>         String path = comma < 0 ? linkPath : linkPath.substring(0, comma);
>         request.clear().setPath(path);
>         if (comma > 0)
>             decodeParametersIntoRequest(path.substring(comma + 1));
>     }
> --------------------
> The path variable is the URL path with the event parameters (?xxx) stripped,
> trying to substring it again cause the IndexOutOfBounds exception. The
> correct variable to pass should instead be: linkPath. A comparison with the
> same class file confirms my findings (see attached).
> My current fix is monkey-patch the PageTester class file. Hopefully this
> will be fixed in next release of T53.
> Regards,
> Kevin Lin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org