In this case we started with relative paths (and the base data directory)
and turned the results into absolute paths as part of the test to make sure
we are pointing at the right file.

The GeoTools method DataUtiltieis.urlToFile is what is being tested here,
and it is letting us down!

    public static File urlToFile(URL url) {
        if (!"file".equals(url.getProtocol())) {
            return null; // not a File URL
        }
        String string = url.toExternalForm();
        if (string.contains("+")) {
            // this represents an invalid URL created using either
            // file.toURL(); or
            // file.toURI().toURL() on a specific version of Java 5 on Mac
            string = string.replace("+", "%2B");
        }
        try {
            string = URLDecoder.decode(string, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Could not decode the URL to UTF-8
format", e);
        }
        String path3;
        String simplePrefix = "file:/";
        String standardPrefix = "file://";
        if (IS_WINDOWS_OS && string.startsWith(standardPrefix)) {
            // win32: host/share reference
            path3 = string.substring(standardPrefix.length() - 2);
        } else if (string.startsWith(standardPrefix)) {
            path3 = string.substring(standardPrefix.length());
        } else if (string.startsWith(simplePrefix)) {
            path3 = string.substring(simplePrefix.length() - 1);
        } else {
            String auth = url.getAuthority();
            String path2 = url.getPath().replace("%20", " ");
            if (auth != null && !auth.equals("")) {
                path3 = "//" + auth + path2;
            } else {
                path3 = path2;
            }
        }
        return new File(path3);
    }

As you can see we have one windows specific control path which we are not
testing anywhere else! I think I may refactor this code to *just* be string
based and take that windows flag as a parameter so we can test this on all
platforms ...

Note these methods were introduced when Java was doing a terrible job of
File to/from URL conversion. They have correcting things a bit with
file.toURI().toURL() ...

If you could grab the geotools codebase and set up a test case that passes
in the same strings that are failing in GeoServer it would be a great
help...
--
Jody

--
Jody Garnett

On 18 January 2015 at 15:58, Olle Markljung <marklj...@gmail.com> wrote:

> Hi,
> I can try to help. We use Windows and GeoServer at work.
> But perhaps I need some guidance..
> This is what the tests gives me. The failing one using file:// and the
> successful one using ./
>
> SLD attribute
> "file://images/rockFillSymbol.png"
>
> Linkage
> file://images/rockFillSymbol.png
>
> Converted to
> \\images\rockFillSymbol.png
>
> SLD attribute
> "./images/rockFillSymbol.png"
>
> Linkage
>
> file:/C:/GitHub/geoserver/src/main/./target/default3970162196491181932data/styles/images/rockFillSymbol.png
>
> Converted to
>
> C:\GitHub\geoserver\src\main\target\default896598906399223139data\styles\images\rockFillSymbol.png
>
> Should "file://images/rockFillSymbol.png" be interpreted as equal to
> "images/rockFillSymbol.png" and "./images/rockFillSymbol.png"?
> According to
> http://stackoverflow.com/questions/7857416/file-uri-scheme-and-relative-files
> you cannot use the file protocol with relative paths.
> So, perhaps this case shouldn't be supported and the test should fail.
>
> /Olle
>
> On Sun, Jan 18, 2015 at 9:05 PM, Jody Garnett <jody.garn...@gmail.com>
> wrote:
>
>> Okay we can consider it a goal for the year ( or a sprint activity if we
>> get a Windows volunteer ).
>> On Sun, Jan 18, 2015 at 12:01 PM Andrea Aime <
>> andrea.a...@geo-solutions.it> wrote:
>>
>>> On Sun, Jan 18, 2015 at 8:06 PM, Jody Garnett <jody.garn...@gmail.com>
>>> wrote:
>>>
>>>> From Simone's email to getools-devel:
>>>>
>>>> a while ago we agree on having a windows build server for geotools
>>>>> which is reachable here:
>>>>> http://winbuild.geo-solutions.it/jenkins
>>>>> credentials are the same for the linux build server.
>>>>
>>>>
>>>> I was able to restore the build for geotools-devel, but it looks like
>>>> we have some failures for the geoserver master build target.
>>>>
>>>> Failed tests:
>>>>> testSEStyleWithRelativePathProtocol(org.geoserver.catalog.ResourcePoolTest):
>>>>> expected:<C:\.jenkins\jobs\GeoServer-Master\workspace\src\main\target\default4702095627624841408data\styles\images\rockFillSymbol.png>
>>>>> but was:<\\images\rockFillSymbol.png>
>>>>
>>>>
>>>> A general call out on this one, I would like to ensure we build cleanly
>>>> on windows (and take advantage of this machine that has been provided).
>>>>
>>>
>>> Hi Jody,
>>> the GeoServer windows build server has never been made "official" because
>>> I did not manage to get the build working on Windows in a stable way
>>> (and got no help doing so either).
>>>
>>> I have a windows laptop now that I can use to do some bits on Windows,
>>> but
>>> honestly I despise the platform, so it's more "call of duty" than
>>> something I want
>>> to do in my spare time, it would need some champion that really
>>> pushes for it.
>>>
>>> Last time I checked there were some random failures in the WCS modules,
>>>  failure to delete some files in the temp data dirs, I guess we are still
>>> keeping some reader/file handle open, but could not locate where.
>>> I guess it got worse from there.
>>>
>>> Cheers
>>> Andrea
>>>
>>> --
>>> ==
>>> GeoServer Professional Services from the experts! Visit
>>> http://goo.gl/NWWaa2 for more information.
>>> ==
>>>
>>> Ing. Andrea Aime
>>> @geowolf
>>> Technical Lead
>>>
>>> GeoSolutions S.A.S.
>>> Via Poggio alle Viti 1187
>>> 55054  Massarosa (LU)
>>> Italy
>>> phone: +39 0584 962313
>>> fax: +39 0584 1660272
>>> mob: +39  339 8844549
>>>
>>> http://www.geo-solutions.it
>>> http://twitter.com/geosolutions_it
>>>
>>> *AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
>>>
>>> Le informazioni contenute in questo messaggio di posta elettronica e/o
>>> nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
>>> loro utilizzo è consentito esclusivamente al destinatario del messaggio,
>>> per le finalità indicate nel messaggio stesso. Qualora riceviate questo
>>> messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
>>> darcene notizia via e-mail e di procedere alla distruzione del messaggio
>>> stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
>>> divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
>>> utilizzarlo per finalità diverse, costituisce comportamento contrario ai
>>> principi dettati dal D.Lgs. 196/2003.
>>>
>>>
>>>
>>> The information in this message and/or attachments, is intended solely
>>> for the attention and use of the named addressee(s) and may be confidential
>>> or proprietary in nature or covered by the provisions of privacy act
>>> (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
>>> Code).Any use not in accord with its purpose, any disclosure, reproduction,
>>> copying, distribution, or either dissemination, either whole or partial, is
>>> strictly forbidden except previous formal approval of the named
>>> addressee(s). If you are not the intended recipient, please contact
>>> immediately the sender by telephone, fax or e-mail and delete the
>>> information in this message that has been received in error. The sender
>>> does not give any warranty or accept liability as the content, accuracy or
>>> completeness of sent messages and accepts no responsibility  for changes
>>> made after they were sent or for other risks which arise as a result of
>>> e-mail transmission, viruses, etc.
>>>
>>> -------------------------------------------------------
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
>> GigeNET is offering a free month of service with a new server in Ashburn.
>> Choose from 2 high performing configs, both with 100TB of bandwidth.
>> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
>> http://p.sf.net/sfu/gigenet
>> _______________________________________________
>> Geoserver-devel mailing list
>> Geoserver-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>>
>>
>
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to