commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Eckenfels (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (VFS-503) Equals on URLFileName should use the complete URL
Date Wed, 19 Aug 2015 09:08:45 GMT

    [ https://issues.apache.org/jira/browse/VFS-503?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14702724#comment-14702724
] 

Bernd Eckenfels edited comment on VFS-503 at 8/19/15 9:08 AM:
--------------------------------------------------------------

I think the following should be a possible unit test, it can be added to GenericFileNameTestCase.java
but I guess creating a new URLFileNameTestCase.java would be better (or renaming it to FileNameTestCase.java?)

{code}
    public void testParseUriParamEquals() throws FileSystemException
    {
        // anchors will be ignored
        final URLFileNameParser urlParser = new URLFileNameParser(80);
        final URLFileName name1a  = (URLFileName)urlParser.parseUri(null, null, "http://host/path?query1#a");
        final URLFileName nameNo1 = (URLFileName)urlParser.parseUri(null, null, "http://host/path#no");
        final URLFileName nameNo2 = (URLFileName)urlParser.parseUri(null, null, "http://host/path");

        // assert it has been correctly parsed
        assertEquals("/path?query1#a", name1a.getPathQuery()); // TODO: anchor?
        assertEquals("query1",         name1a.getQueryString());
        assertEquals("/path#no",       nameNo1.getPathQuery()); // TODO: anchor?
        assertEquals("/path",          nameNo2.getPathQuery());
        assertNull(nameNo1.getQueryString());
        assertNull(nameNo2.getQueryString());

        final FileName name1b = urlParser.parseUri(null, null, "http://host/path?query1#b");
        final FileName name2  = urlParser.parseUri(null, null, "http://host/path?query2");

        assertEquals(name1a, name1b);     // ?query1#a == ?query1#b
        assertNotEquals(name1a, name2);   // ?query1#a != ?query2
        assertNotEquals(name1b, name2);   // ?query1#b != ?query2
        assertNotEquals(name1a, nameNo1); // ?query1#a != ?#no
        assertNotEquals(name2,  nameNo1); // ?query2   != ?#no
        assertNotEquals(name1b, nameNo2); // ?query1#b != ?
        assertNotEquals(name2,  nameNo2); // ?query2   != ?
    }
{code}


was (Author: b.eckenfels):
I think the following should be a possible unit test, it can be added to GenericFileNameTestCase.java
but I guess creating a new URLFileNameTestCase.java would be better (or renaming it to FileNameTestCase.java?)

{code}
    public void testParseUriParamEquals() throws FileSystemException
    {
        // anchors will be ignored
        final URLFileNameParser urlParser = new URLFileNameParser(80);
        final FileName name1a = urlParser.parseUri(null, null, "http://host/path?query1#a");
        final URLFileName nameNo1 = (URLFileName)urlParser.parseUri(null, null, "http://host/path#no");
        final URLFileName nameNo2 = (URLFileName)urlParser.parseUri(null, null, "http://host/path");

        // assert it has been correctly parsed
        assertEquals("/path?query1#a", ((URLFileName)name1a).getPathQuery()); // TODO: anchor?
        assertEquals("query1", ((URLFileName)name1a).getQueryString());
        assertEquals("/path#no", nameNo1.getPathQuery()); // TODO: anchor?
        assertNull(nameNo1.getQueryString());
        assertEquals("/path", nameNo2.getPathQuery());
        assertNull(nameNo2.getQueryString());

        assertNull(((URLFileName)nameNo1).getQueryString());
        assertNull(((URLFileName)nameNo2).getQueryString());

        final FileName name1b = urlParser.parseUri(null, null, "http://host/path?query1#b");
        final FileName name2  = urlParser.parseUri(null, null, "http://host/path?query2");

        assertEquals(name1a, name1b);     // ?query1#a == ?query1#b
        assertNotEquals(name1a, name2);   // ?query1#a != ?query2
        assertNotEquals(name1b, name2);   // ?query1#b != ?query2
        assertNotEquals(name1a, nameNo1); // ?query1#a != ?#no
        assertNotEquals(name2,  nameNo1); // ?query2   != ?#no
        assertNotEquals(name1b, nameNo2); // ?query1#b != ?
        assertNotEquals(name2,  nameNo2); // ?query2   != ?
    }
{code}

> Equals on URLFileName should use the complete URL
> -------------------------------------------------
>
>                 Key: VFS-503
>                 URL: https://issues.apache.org/jira/browse/VFS-503
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Dominique Jean-Prost
>            Priority: Critical
>              Labels: patch
>         Attachments: patch.txt, test-vfs.zip
>
>
> Hello,
> When using http url that uses query parameters, the method resolveFile doesn not work
correctly.
> Problem is caused by the fact that equals on org.apache.commons.vfs2.provider.URLFileName
does not use the query string.
> The consequence of this bug is that if you use 2 FileObject that use 2 differents URLS,
that denote 2 different contents, you would use twice the same content when using copyForm
for instance (see attached maven project)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message