Changeset 15034 in josm


Ignore:
Timestamp:
2019-05-02T04:33:57+02:00 (6 years ago)
Author:
Don-vip
Message:

checkstyle/PMD

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/.checkstyle

    r14417 r15034  
    1818    <filter-data value="src/org/openstreetmap/gui"/>
    1919    <filter-data value="src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen"/>
     20    <filter-data value="src/org/tukaani"/>
     21    <filter-data value=".externalToolBuilders"/>
     22    <filter-data value=".settings"/>
    2023    <filter-data value=".svn"/>
     24    <filter-data value="bin"/>
     25    <filter-data value="bintest"/>
     26    <filter-data value="build"/>
     27    <filter-data value="build2"/>
    2128    <filter-data value="data"/>
     29    <filter-data value="data_nodist"/>
     30    <filter-data value="dist"/>
     31    <filter-data value="eclipse"/>
    2232    <filter-data value="images"/>
     33    <filter-data value="images_nodist"/>
    2334    <filter-data value="javadoc"/>
     35    <filter-data value="linux"/>
     36    <filter-data value="macosx"/>
     37    <filter-data value="netbeans"/>
     38    <filter-data value="patches"/>
    2439    <filter-data value="resources"/>
    2540    <filter-data value="styles"/>
    26     <filter-data value="scripts"/>
     41    <filter-data value="styles_nodist"/>
     42    <filter-data value="test/build"/>
     43    <filter-data value="test/config"/>
     44    <filter-data value="test/data"/>
     45    <filter-data value="test/lib"/>
     46    <filter-data value="test/report"/>
     47    <filter-data value="tools"/>
     48    <filter-data value="windows"/>
    2749  </filter>
    2850</fileset-config>
  • trunk/build.xml

    r15033 r15034  
    4747        <property name="failureaccess.jar" location="${tools.dir}/failureaccess.jar"/>
    4848        <property name="guava.jar" location="${tools.dir}/guava.jar"/>
    49         <property name="commons-lang3.jar" location="${pmd.dir}/commons-lang3-3.8.1.jar"/>
     49        <property name="commons-lang3.jar" location="${pmd.dir}/commons-lang3-3.8.1.jar"/>
    5050        <property name="jformatstring.jar" location="${spotbugs.dir}/jFormatString-3.0.0.jar"/>
    5151        <property name="dist.jar" location="${dist.dir}/josm-custom.jar"/>
  • trunk/scripts/SyncEditorLayerIndex.java

    r15033 r15034  
    11// License: GPL. For details, see LICENSE file.
     2import static java.nio.charset.StandardCharsets.UTF_8;
    23import static org.apache.commons.lang3.StringUtils.isBlank;
    34import static org.apache.commons.lang3.StringUtils.isNotBlank;
    45
    56import java.io.BufferedReader;
    6 import java.io.FileInputStream;
    7 import java.io.FileNotFoundException;
    8 import java.io.FileOutputStream;
    97import java.io.IOException;
    108import java.io.InputStreamReader;
     9import java.io.OutputStream;
    1110import java.io.OutputStreamWriter;
    12 import java.io.UnsupportedEncodingException;
    1311import java.lang.reflect.Field;
     12import java.nio.file.Files;
     13import java.nio.file.Paths;
    1414import java.text.DecimalFormat;
    1515import java.text.ParseException;
     
    5050import org.openstreetmap.josm.io.imagery.ImageryReader;
    5151import org.openstreetmap.josm.spi.preferences.Config;
     52import org.openstreetmap.josm.tools.Logging;
    5253import org.openstreetmap.josm.tools.OptionParser;
    5354import org.openstreetmap.josm.tools.OptionParser.OptionCount;
     
    7475public class SyncEditorLayerIndex {
    7576
     77    private static final int MAXLEN = 140;
     78
    7679    private List<ImageryInfo> josmEntries;
    7780    private JsonArray eliEntries;
    7881
    79     private Map<String, JsonObject> eliUrls = new HashMap<>();
    80     private Map<String, ImageryInfo> josmUrls = new HashMap<>();
    81     private Map<String, ImageryInfo> josmMirrors = new HashMap<>();
    82     private static Map<String, String> oldproj = new HashMap<>();
    83     private static List<String> ignoreproj = new LinkedList<>();
     82    private final Map<String, JsonObject> eliUrls = new HashMap<>();
     83    private final Map<String, ImageryInfo> josmUrls = new HashMap<>();
     84    private final Map<String, ImageryInfo> josmMirrors = new HashMap<>();
     85    private static final Map<String, String> oldproj = new HashMap<>();
     86    private static final List<String> ignoreproj = new LinkedList<>();
    8487
    8588    private static String eliInputFile = "imagery_eli.geojson";
    8689    private static String josmInputFile = "imagery_josm.imagery.xml";
    8790    private static String ignoreInputFile = "imagery_josm.ignores.txt";
    88     private static FileOutputStream outputFile = null;
    89     private static OutputStreamWriter outputStream = null;
     91    private static OutputStream outputFile;
     92    private static OutputStreamWriter outputStream;
    9093    private static String optionOutput;
    9194    private static boolean optionShorten;
     
    108111    public static void main(String[] args) throws IOException, SAXException, ReflectiveOperationException {
    109112        Locale.setDefault(Locale.ROOT);
    110         parse_command_line_arguments(args);
     113        parseCommandLineArguments(args);
    111114        Preferences pref = new Preferences(JosmBaseDirectories.getInstance());
    112115        Config.setPreferencesInstance(pref);
     
    118121        script.loadJosmEntries();
    119122        if (optionJosmXml != null) {
    120             FileOutputStream file = new FileOutputStream(optionJosmXml);
    121             OutputStreamWriter stream = new OutputStreamWriter(file, "UTF-8");
    122             script.printentries(script.josmEntries, stream);
    123             stream.close();
    124             file.close();
     123            try (OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionJosmXml)), UTF_8)) {
     124                script.printentries(script.josmEntries, stream);
     125            }
    125126        }
    126127        script.loadELIEntries();
    127128        if (optionEliXml != null) {
    128             FileOutputStream file = new FileOutputStream(optionEliXml);
    129             OutputStreamWriter stream = new OutputStreamWriter(file, "UTF-8");
    130             script.printentries(script.eliEntries, stream);
    131             stream.close();
    132             file.close();
     129            try (OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionEliXml)), UTF_8)) {
     130                script.printentries(script.eliEntries, stream);
     131            }
    133132        }
    134133        script.checkInOneButNotTheOther();
     
    154153        return "usage: java -cp build SyncEditorLayerIndex\n" +
    155154        "-c,--encoding <encoding>           output encoding (defaults to UTF-8 or cp850 on Windows)\n" +
    156         "-e,--eli_input <eli_input>         Input file for the editor layer index (geojson). Default is imagery_eli.geojson (current directory).\n" +
     155        "-e,--eli_input <eli_input>         Input file for the editor layer index (geojson). " +
     156                                            "Default is imagery_eli.geojson (current directory).\n" +
    157157        "-h,--help                          show this help\n" +
    158158        "-i,--ignore_input <ignore_input>   Input file for the ignore list. Default is imagery_josm.ignores.txt (current directory).\n" +
    159         "-j,--josm_input <josm_input>       Input file for the JOSM imagery list (xml). Default is imagery_josm.imagery.xml (current directory).\n" +
     159        "-j,--josm_input <josm_input>       Input file for the JOSM imagery list (xml). " +
     160                                            "Default is imagery_josm.imagery.xml (current directory).\n" +
    160161        "-m,--noeli                         don't show output for ELI problems\n" +
    161162        "-n,--noskip                        don't skip known entries\n" +
     
    171172     * Parse command line arguments.
    172173     * @param args program arguments
    173      * @throws FileNotFoundException if a file can't be found
    174      * @throws UnsupportedEncodingException  if the given encoding can't be found
     174     * @throws IOException in case of I/O error
    175175     */
    176     static void parse_command_line_arguments(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
     176    static void parseCommandLineArguments(String[] args) throws IOException {
    177177        new OptionParser("JOSM/ELI synchronization script")
    178178                .addFlagParameter("help", SyncEditorLayerIndex::showHelp)
     
    204204                .parseOptionsOrExit(Arrays.asList(args));
    205205
    206         if (optionOutput != null && optionOutput != "-") {
    207             outputFile = new FileOutputStream(optionOutput);
     206        if (optionOutput != null && !"-".equals(optionOutput)) {
     207            outputFile = Files.newOutputStream(Paths.get(optionOutput));
    208208            outputStream = new OutputStreamWriter(outputFile, optionEncoding != null ? optionEncoding : "UTF-8");
    209209        } else if (optionEncoding != null) {
     
    233233    void loadSkip() throws IOException {
    234234        final Pattern pattern = Pattern.compile("^\\|\\| *(ELI|Ignore) *\\|\\| *\\{\\{\\{(.+)\\}\\}\\} *\\|\\|");
    235         try (BufferedReader fr = new BufferedReader(new InputStreamReader(new FileInputStream(ignoreInputFile), "UTF-8"))) {
     235        try (BufferedReader fr = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(ignoreInputFile)), UTF_8))) {
    236236            String line;
    237237
     
    262262            skip.remove(s);
    263263            if (optionXhtmlBody || optionXhtml) {
    264                 s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")+"</pre>";
     264                s = "<pre style=\"margin:3px;color:"+color+"\">"
     265                        + s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
    265266            }
    266267            if (!optionNoSkip) {
    267268                return;
    268269            }
    269         } else if(optionXhtmlBody || optionXhtml) {
     270        } else if (optionXhtmlBody || optionXhtml) {
    270271            String color =
    271272                    s.startsWith("***") ? "black" :
     
    273274                            (s.startsWith("#") ? "indigo" :
    274275                                (s.startsWith("!") ? "orange" : "red")));
    275             s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")+"</pre>";
     276            s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
    276277        }
    277278        if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && optionNoEli) {
     
    283284    void start() throws IOException {
    284285        if (optionXhtml) {
    285             myprintlnfinal("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
    286             myprintlnfinal("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><title>JOSM - ELI differences</title></head><body>\n");
     286            myprintlnfinal(
     287                    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
     288            myprintlnfinal(
     289                    "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"+
     290                    "<title>JOSM - ELI differences</title></head><body>\n");
    287291        }
    288292    }
     
    298302
    299303    void loadELIEntries() throws IOException {
    300         try (JsonReader jr = Json.createReader(new InputStreamReader(new FileInputStream(eliInputFile), "UTF-8"))) {
     304        try (JsonReader jr = Json.createReader(new InputStreamReader(Files.newInputStream(Paths.get(eliInputFile)), UTF_8))) {
    301305            eliEntries = jr.readObject().getJsonArray("features");
    302306        }
     
    306310            if (url.contains("{z}")) {
    307311                myprintln("+++ ELI-URL uses {z} instead of {zoom}: "+url);
    308                 url = url.replace("{z}","{zoom}");
     312                url = url.replace("{z}", "{zoom}");
    309313            }
    310314            if (eliUrls.containsKey(url)) {
     
    355359            if (p != null) {
    356360                res += offset + "<projections>\n";
    357                 for (String c : p)
     361                for (String c : p) {
    358362                    res += offset + "    <code>"+c+"</code>\n";
     363                }
    359364                res += offset + "</projections>\n";
    360365            }
     
    370375        for (Object e : entries) {
    371376            stream.write("    <entry"
    372                 + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "" )
    373                 + (getOverlay(e) ? " overlay=\"true\"" : "" )
     377                + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "")
     378                + (getOverlay(e) ? " overlay=\"true\"" : "")
    374379                + ">\n");
    375380            String t;
     
    428433                        if (lat < minlat) minlat = lat;
    429434                        if (lon < minlon) minlon = lon;
    430                         if ((i++%3) == 0) {
     435                        if ((i++ % 3) == 0) {
    431436                            shapes += sep + "    ";
    432437                        }
     
    435440                    shapes += sep + "</shape>\n";
    436441                }
    437             } catch(IllegalArgumentException ignored) {
     442            } catch (IllegalArgumentException ignored) {
     443                Logging.trace(ignored);
    438444            }
    439445            if (!shapes.isEmpty()) {
    440                 stream.write("        <bounds min-lat='"+df.format(minlat)+"' min-lon='"+df.format(minlon)+"' max-lat='"+df.format(maxlat)+"' max-lon='"+df.format(maxlon)+"'>\n");
     446                stream.write("        <bounds min-lat='"+df.format(minlat)
     447                                          +"' min-lon='"+df.format(minlon)
     448                                          +"' max-lat='"+df.format(maxlat)
     449                                          +"' max-lon='"+df.format(maxlon)+"'>\n");
    441450                stream.write(shapes + "        </bounds>\n");
    442451            }
     
    464473            if (url.contains("{z}")) {
    465474                myprintln("+++ JOSM-URL uses {z} instead of {zoom}: "+url);
    466                 url = url.replace("{z}","{zoom}");
     475                url = url.replace("{z}", "{zoom}");
    467476            }
    468477            if (josmUrls.containsKey(url)) {
     
    475484                Field origNameField = ImageryInfo.class.getDeclaredField("origName");
    476485                ReflectionUtils.setObjectsAccessible(origNameField);
    477                 origNameField.set(m, m.getOriginalName().replaceAll(" mirror server( \\d+)?",""));
     486                origNameField.set(m, m.getOriginalName().replaceAll(" mirror server( \\d+)?", ""));
    478487                if (josmUrls.containsKey(url)) {
    479488                    myprintln("+++ JOSM-Mirror-URL is not unique: "+url);
     
    504513                JsonObject e = eliUrls.get(urle);
    505514                String ide = getId(e);
    506                 String urlhttps = urle.replace("http:","https:");
     515                String urlhttps = urle.replace("http:", "https:");
    507516                if (lj.contains(urlhttps)) {
    508517                    myprintln("+ Missing https: "+getDescription(e));
     
    523532                            // replace key for this entry with JOSM URL
    524533                            eliUrls.remove(urle);
    525                             eliUrls.put(urlj,e);
     534                            eliUrls.put(urlj, e);
    526535                            break;
    527536                        }
     
    548557
    549558    void checkCommonEntries() throws IOException {
     559        doSameUrlButDifferentName();
     560        doSameUrlButDifferentId();
     561        doSameUrlButDifferentType();
     562        doSameUrlButDifferentZoomBounds();
     563        doSameUrlButDifferentCountryCode();
     564        doSameUrlButDifferentQuality();
     565        doSameUrlButDifferentDates();
     566        doSameUrlButDifferentInformation();
     567        doMismatchingShapes();
     568        doMismatchingIcons();
     569        doMiscellaneousChecks();
     570    }
     571
     572    void doSameUrlButDifferentName() throws IOException {
    550573        myprintln("*** Same URL, but different name: ***");
    551574        for (String url : eliUrls.keySet()) {
     
    553576            if (!josmUrls.containsKey(url)) continue;
    554577            ImageryInfo j = josmUrls.get(url);
    555             String ename = getName(e).replace("'","\u2019");
    556             String jname = getName(j).replace("'","\u2019");
     578            String ename = getName(e).replace("'", "\u2019");
     579            String jname = getName(j).replace("'", "\u2019");
    557580            if (!ename.equals(jname)) {
    558581                myprintln("* Name differs ('"+getName(e)+"' != '"+getName(j)+"'): "+getUrl(j));
    559582            }
    560583        }
    561 
     584    }
     585
     586    void doSameUrlButDifferentId() throws IOException {
    562587        myprintln("*** Same URL, but different Id: ***");
    563588        for (String url : eliUrls.keySet()) {
     
    571596            }
    572597        }
    573 
     598    }
     599
     600    void doSameUrlButDifferentType() throws IOException {
    574601        myprintln("*** Same URL, but different type: ***");
    575602        for (String url : eliUrls.keySet()) {
     
    581608            }
    582609        }
    583 
     610    }
     611
     612    void doSameUrlButDifferentZoomBounds() throws IOException {
    584613        myprintln("*** Same URL, but different zoom bounds: ***");
    585614        for (String url : eliUrls.keySet()) {
     
    605634            }
    606635        }
    607 
     636    }
     637
     638    void doSameUrlButDifferentCountryCode() throws IOException {
    608639        myprintln("*** Same URL, but different country code: ***");
    609640        for (String url : eliUrls.keySet()) {
     
    619650            }
    620651        }
     652    }
     653
     654    void doSameUrlButDifferentQuality() throws IOException {
    621655        myprintln("*** Same URL, but different quality: ***");
    622656        for (String url : eliUrls.keySet()) {
     
    634668            }
    635669        }
     670    }
     671
     672    void doSameUrlButDifferentDates() throws IOException {
    636673        myprintln("*** Same URL, but different dates: ***");
    637674        Pattern pattern = Pattern.compile("^(.*;)(\\d\\d\\d\\d)(-(\\d\\d)(-(\\d\\d))?)?$");
     
    642679            String jd = getDate(j);
    643680            // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015
    644             String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z", "$1");
     681            String ef = ed.replaceAll("\\A-;", "").replaceAll(";-\\z", "").replaceAll("\\A([0-9-]+);\\1\\z", "$1");
    645682            // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one
    646683            String ed2 = ed;
     
    658695                    ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH));
    659696            }
    660             String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z", "$1");
     697            String ef2 = ed2.replaceAll("\\A-;", "").replaceAll(";-\\z", "").replaceAll("\\A([0-9-]+);\\1\\z", "$1");
    661698            if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) {
    662699                String t = "'"+ed+"'";
     
    673710            }
    674711        }
     712    }
     713
     714    void doSameUrlButDifferentInformation() throws IOException {
    675715        myprintln("*** Same URL, but different information: ***");
    676716        for (String url : eliUrls.keySet()) {
     
    723763                    myprintln("- Missing JOSM attribution URL ("+et+"): "+getDescription(j));
    724764                } else if (isNotBlank(et)) {
    725                     String ethttps = et.replace("http:","https:");
     765                    String ethttps = et.replace("http:", "https:");
    726766                    if (jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) {
    727767                        myprintln("+ Attribution URL differs ('"+et+"' != '"+jt+"'): "+getDescription(j));
     
    786826            }
    787827        }
     828    }
     829
     830    void doMismatchingShapes() throws IOException {
    788831        myprintln("*** Mismatching shapes: ***");
    789832        for (String url : josmUrls.keySet()) {
     
    792835            for (Shape shape : getShapes(j)) {
    793836                List<Coordinate> p = shape.getPoints();
    794                 if(!p.get(0).equals(p.get(p.size()-1))) {
     837                if (!p.get(0).equals(p.get(p.size()-1))) {
    795838                    myprintln("+++ JOSM shape "+num+" unclosed: "+getDescription(j));
    796839                }
     
    811854                for (Shape shape : s) {
    812855                    List<Coordinate> p = shape.getPoints();
    813                     if(!p.get(0).equals(p.get(p.size()-1)) && !optionNoEli) {
     856                    if (!p.get(0).equals(p.get(p.size()-1)) && !optionNoEli) {
    814857                        myprintln("+++ ELI shape "+num+" unclosed: "+getDescription(e));
    815858                    }
     
    834877                    myprintln("+ No ELI shape: "+getDescription(j));
    835878                }
    836             } else if(js.isEmpty() && !s.isEmpty()) {
     879            } else if (js.isEmpty() && !s.isEmpty()) {
    837880                // don't report boundary like 5 point shapes as difference
    838881                if (s.size() != 1 || s.get(0).getPoints().size() != 5) {
    839882                    myprintln("- No JOSM shape: "+getDescription(j));
    840883                }
    841             } else if(s.size() != js.size()) {
     884            } else if (s.size() != js.size()) {
    842885                myprintln("* Different number of shapes ("+s.size()+" != "+js.size()+"): "+getDescription(j));
    843886            } else {
     
    850893                        if (ep.size() == jp.size() && !jdone[jnums]) {
    851894                            boolean err = false;
    852                             for(int nump = 0; nump < ep.size() && !err; ++nump) {
     895                            for (int nump = 0; nump < ep.size() && !err; ++nump) {
    853896                                Coordinate ept = ep.get(nump);
    854897                                Coordinate jpt = jp.get(nump);
    855                                 if(Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001)
     898                                if (Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001)
    856899                                    err = true;
    857900                            }
    858                             if(!err) {
     901                            if (!err) {
    859902                                edone[enums] = true;
    860903                                jdone[jnums] = true;
     
    897940                                numtxt += '/' + Integer.toString(jnums+1);
    898941                            }
    899                             myprintln("* Different number of points for shape "+numtxt+" ("+ep.size()+" ! = "+jp.size()+")): "+getDescription(j));
     942                            myprintln("* Different number of points for shape "+numtxt+" ("+ep.size()+" ! = "+jp.size()+")): "
     943                                    + getDescription(j));
    900944                            edone[enums] = true;
    901945                            jdone[jnums] = true;
     
    906950            }
    907951        }
     952    }
     953
     954    void doMismatchingIcons() throws IOException {
    908955        myprintln("*** Mismatching icons: ***");
    909956        for (String url : eliUrls.keySet()) {
     
    927974              || ie.startsWith("https://raw.githubusercontent.com/osmlab/editor-layer-index/")) &&
    928975              ij.startsWith("data:"))) {
    929                 String iehttps = ie.replace("http:","https:");
     976                String iehttps = ie.replace("http:", "https:");
    930977                if (ij.equals(iehttps)) {
    931978                    myprintln("+ Different icons: "+getDescription(j));
     
    935982            }
    936983        }
     984    }
     985
     986    void doMiscellaneousChecks() throws IOException {
    937987        myprintln("*** Miscellaneous checks: ***");
    938988        Map<String, ImageryInfo> josmIds = new HashMap<>();
     
    9641014                    }
    9651015                    for (String o : old) {
    966                         myprintln("* Projection "+o+" is an old unsupported code and has been replaced by "+oldproj.get(o)+": "+getDescription(j));
     1016                        myprintln("* Projection "+o+" is an old unsupported code and has been replaced by "+oldproj.get(o)+": "
     1017                                + getDescription(j));
    9671018                    }
    9681019                }
     
    9951046                    myprintln("* Strange URL '"+u+"': "+getDescription(j));
    9961047                } else {
    997                     String domain = m.group(1).replaceAll("\\{switch:.*\\}","x");
     1048                    String domain = m.group(1).replaceAll("\\{switch:.*\\}", "x");
    9981049                    String port = m.group(2);
    9991050                    if (!(domain.matches("^\\d+\\.\\d+\\.\\d+\\.\\d+$")) && !dv.isValid(domain))
     
    10281079                            myprintln("* JOSM-Date '"+d+"' is strange (second earlier than first): "+getDescription(j));
    10291080                        }
    1030                     }
    1031                     catch (Exception e) {
     1081                    } catch (Exception e) {
    10321082                        myprintln("* JOSM-Date '"+d+"' is strange ("+e.getMessage()+"): "+getDescription(j));
    10331083                    }
     
    10531103                        double lat = p.getLat();
    10541104                        double lon = p.getLon();
    1055                         if(lat > maxlat) maxlat = lat;
    1056                         if(lon > maxlon) maxlon = lon;
    1057                         if(lat < minlat) minlat = lat;
    1058                         if(lon < minlon) minlon = lon;
     1105                        if (lat > maxlat) maxlat = lat;
     1106                        if (lon > maxlon) maxlon = lon;
     1107                        if (lat < minlat) minlat = lat;
     1108                        if (lon < minlon) minlon = lon;
    10591109                    }
    10601110                }
     
    10621112                if (b.getMinLat() != minlat || b.getMinLon() != minlon || b.getMaxLat() != maxlat || b.getMaxLon() != maxlon) {
    10631113                    myprintln("* Bounds do not match shape (is "+b.getMinLat()+","+b.getMinLon()+","+b.getMaxLat()+","+b.getMaxLon()
    1064                         + ", calculated <bounds min-lat='"+minlat+"' min-lon='"+minlon+"' max-lat='"+maxlat+"' max-lon='"+maxlon+"'>): "+getDescription(j));
     1114                        + ", calculated <bounds min-lat='"+minlat+"' min-lon='"+minlon+"' max-lat='"+maxlat+"' max-lon='"+maxlon+"'>): "
     1115                        + getDescription(j));
    10651116                }
    10661117            }
     
    10851136
    10861137    static String getUrlStripped(Object e) {
    1087         return getUrl(e).replaceAll("\\?(apikey|access_token)=.*","");
     1138        return getUrl(e).replaceAll("\\?(apikey|access_token)=.*", "");
    10881139    }
    10891140
     
    10931144        String start = p.containsKey("start_date") ? p.getString("start_date") : "";
    10941145        String end = p.containsKey("end_date") ? p.getString("end_date") : "";
    1095         if(!start.isEmpty() && !end.isEmpty())
     1146        if (!start.isEmpty() && !end.isEmpty())
    10961147            return start+";"+end;
    1097         else if(!start.isEmpty())
     1148        else if (!start.isEmpty())
    10981149            return start+";-";
    1099         else if(!end.isEmpty())
     1150        else if (!end.isEmpty())
    11001151            return "-;"+end;
    11011152        return "";
     
    11041155    static Date verifyDate(String year, String month, String day) throws ParseException {
    11051156        String date;
    1106         if(year == null) {
     1157        if (year == null) {
    11071158            date = "3000-01-01";
    11081159        } else {
     
    11611212        if (e instanceof ImageryInfo) {
    11621213            ImageryBounds bounds = ((ImageryInfo) e).getBounds();
    1163             if(bounds != null) {
     1214            if (bounds != null) {
    11641215                return bounds.getShapes();
    11651216            }
     
    12831334    }
    12841335
    1285     static Map<String,String> getDescriptions(Object e) {
    1286         Map<String,String> res = new HashMap<String, String>();
     1336    static Map<String, String> getDescriptions(Object e) {
     1337        Map<String, String> res = new HashMap<String, String>();
    12871338        if (e instanceof ImageryInfo) {
    12881339            String a = ((ImageryInfo) e).getDescription();
     
    12901341        } else {
    12911342            String a = ((Map<String, JsonObject>) e).get("properties").getString("description", null);
    1292             if (a != null) res.put("en", a.replaceAll("''","'"));
     1343            if (a != null) res.put("en", a.replaceAll("''", "'"));
    12931344        }
    12941345        return res;
     
    13231374        String d = cc + getName(o) + " - " + getUrl(o);
    13241375        if (optionShorten) {
    1325             final int MAXLEN = 140;
    13261376            if (d.length() > MAXLEN) d = d.substring(0, MAXLEN-1) + "...";
    13271377        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r15015 r15034  
    595595        }
    596596
    597         private static String lc(String s) {
     597        private static String lower(String s) {
    598598            return s.toLowerCase(Locale.ENGLISH);
    599599        }
    600600
    601601        static String validateUploadTag(String uploadValue, String preferencePrefix, List<String> defMandatory, List<String> defForbidden) {
    602             String uploadValueLc = lc(uploadValue);
     602            String uploadValueLc = lower(uploadValue);
    603603            // Check mandatory terms
    604604            List<String> missingTerms = Config.getPref().getList(preferencePrefix+".mandatory-terms", defMandatory)
    605                 .stream().map(UploadAction::lc).filter(x -> !uploadValueLc.contains(x)).collect(Collectors.toList());
     605                .stream().map(UploadAction::lower).filter(x -> !uploadValueLc.contains(x)).collect(Collectors.toList());
    606606            if (!missingTerms.isEmpty()) {
    607607                return tr("The following required terms are missing: {0}", missingTerms);
     
    609609            // Check forbidden terms
    610610            List<String> forbiddenTerms = Config.getPref().getList(preferencePrefix+".forbidden-terms", defForbidden)
    611                     .stream().map(UploadAction::lc).filter(uploadValueLc::contains).collect(Collectors.toList());
     611                    .stream().map(UploadAction::lower).filter(uploadValueLc::contains).collect(Collectors.toList());
    612612            if (!forbiddenTerms.isEmpty()) {
    613613                return tr("The following forbidden terms have been found: {0}", forbiddenTerms);
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r14120 r15034  
    1010import java.awt.image.BufferedImage;
    1111import java.io.File;
    12 import java.io.FileInputStream;
    13 import java.io.FileNotFoundException;
    1412import java.io.IOException;
     13import java.nio.file.Files;
     14import java.nio.file.Paths;
    1515import java.text.MessageFormat;
    1616import java.util.ArrayList;
     
    345345        }
    346346
    347         public DataSet getOsmDataSet() throws FileNotFoundException, IllegalDataException {
     347        public DataSet getOsmDataSet() throws IllegalDataException, IOException {
    348348            if (ds == null) {
    349                 ds = OsmReader.parseDataSet(new FileInputStream(getTestDirectory() + "/data.osm"), null);
     349                ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(getTestDirectory(), "data.osm")), null);
    350350            }
    351351            return ds;
    352352        }
    353353
    354         public Bounds getTestArea() throws FileNotFoundException, IllegalDataException {
     354        public Bounds getTestArea() throws IllegalDataException, IOException {
    355355            if (testArea == null) {
    356356                testArea = getOsmDataSet().getDataSourceBounds().get(0);
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java

    r14582 r15034  
    77import java.awt.image.BufferedImage;
    88import java.io.File;
    9 import java.io.FileInputStream;
    109import java.io.IOException;
    1110import java.io.InputStream;
     11import java.nio.file.Files;
     12import java.nio.file.Paths;
    1213
    1314import javax.imageio.ImageIO;
     
    8081        StyledMapRenderer.PREFERENCE_TEXT_ANTIALIASING.put("gasp");
    8182
    82         try (InputStream fisR = new FileInputStream("data_nodist/restriction.osm");
    83                 InputStream fisM = new FileInputStream("data_nodist/multipolygon.osm");
    84                 InputStream fisC = Compression.getUncompressedFileInputStream(new File("data_nodist/neubrandenburg.osm.bz2"));
    85                 InputStream fisO = Compression.getUncompressedFileInputStream(new File("data_nodist/overpass-download.osm.bz2"));) {
     83        try (InputStream fisR = Files.newInputStream(Paths.get("data_nodist/restriction.osm"));
     84             InputStream fisM = Files.newInputStream(Paths.get("data_nodist/multipolygon.osm"));
     85             InputStream fisC = Compression.getUncompressedFileInputStream(new File("data_nodist/neubrandenburg.osm.bz2"));
     86             InputStream fisO = Compression.getUncompressedFileInputStream(new File("data_nodist/overpass-download.osm.bz2"));) {
    8687            dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE);
    8788            dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE);
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r12740 r15034  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.io.FileInputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.Collection;
    89import java.util.Map;
     
    7475    @Test
    7576    public void testCreate1() throws Exception {
    76         DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
     77        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    7778        Pair<SequenceCommand, Relation> mp = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null);
    7879        assertEquals("Sequence: Create multipolygon", mp.a.getDescriptionText());
     
    8283    @Test
    8384    public void testCreate2() throws Exception {
    84         DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
     85        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    8586        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true);
    8687        assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp).toString());
     
    8990    @Test
    9091    public void testUpdate1() throws Exception {
    91         DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
     92        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    9293        Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true);
    9394        assertEquals(3, mp.getMembersCount());
     
    100101    @Test
    101102    public void testUpdate2() throws Exception {
    102         DataSet ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);
     103        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    103104        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true);
    104105        assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp).toString());
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r14138 r15034  
    55import static org.junit.Assert.assertTrue;
    66
    7 import java.io.FileInputStream;
    87import java.io.IOException;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.Arrays;
    1112import java.util.Collection;
     
    106107    public void testExamples() throws Exception {
    107108        DataSet dsToJoin, dsExpected;
    108         try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests.osm")) {
     109        try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests.osm"))) {
    109110            dsToJoin = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    110111        }
    111         try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests_joined.osm")) {
     112        try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests_joined.osm"))) {
    112113            dsExpected = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    113114        }
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r12656 r15034  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.io.FileInputStream;
     6import java.io.InputStream;
     7import java.nio.file.Files;
     8import java.nio.file.Paths;
    79import java.util.ArrayList;
    810import java.util.List;
     
    9799
    98100    DataSet performTest(String... search) throws Exception {
    99         try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "orthogonalize.osm")) {
     101        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "orthogonalize.osm"))) {
    100102            final DataSet ds = OsmReader.parseDataSet(in, null);
    101103            // TODO: Executing commands depends on active edit layer
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r13079 r15034  
    66import static org.junit.Assert.assertTrue;
    77
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.Arrays;
    1112import java.util.Collection;
     
    7374        for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) {
    7475            DataSet ds;
    75             try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) {
     76            try (InputStream is = Files.newInputStream(Paths.get("data_nodist/filterTests.osm"))) {
    7677                ds = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    7778            }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r14120 r15034  
    44import static org.openstreetmap.josm.TestUtils.getPrivateField;
    55
    6 import java.io.FileInputStream;
    76import java.io.InputStream;
     7import java.nio.file.Files;
     8import java.nio.file.Paths;
    89import java.security.SecureRandom;
    910import java.util.ArrayList;
     
    8485    public void testRemove() throws Exception {
    8586        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    86         try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
     87        try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) {
    8788            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    8889            removeAllTest(ds);
     
    9798    public void testMove() throws Exception {
    9899        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    99         try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
     100        try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) {
    100101            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    101102
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r14273 r15034  
    55import java.io.BufferedWriter;
    66import java.io.File;
    7 import java.io.FileInputStream;
    8 import java.io.FileOutputStream;
    97import java.io.IOException;
    108import java.io.InputStream;
     
    1513import java.lang.reflect.Method;
    1614import java.nio.charset.StandardCharsets;
     15import java.nio.file.Files;
     16import java.nio.file.Paths;
    1717import java.security.SecureRandom;
    1818import java.util.ArrayList;
     
    121121        }
    122122        try (BufferedReader in = new BufferedReader(new InputStreamReader(
    123                 new FileInputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {
     123                Files.newInputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) {
    124124            String line;
    125125            Pattern projPattern = Pattern.compile("<(.+?)>(.*)<>");
     
    357357        }
    358358        try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
    359                 new FileOutputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {
     359                Files.newOutputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) {
    360360            for (Map.Entry<String, RefEntry> e : refsMap.entrySet()) {
    361361                RefEntry ref = e.getValue();
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r13702 r15034  
    55import java.io.BufferedWriter;
    66import java.io.File;
    7 import java.io.FileInputStream;
    87import java.io.FileNotFoundException;
    9 import java.io.FileOutputStream;
    108import java.io.IOException;
    119import java.io.InputStreamReader;
    1210import java.io.OutputStreamWriter;
    1311import java.nio.charset.StandardCharsets;
     12import java.nio.file.Files;
     13import java.nio.file.Paths;
    1414import java.security.SecureRandom;
    1515import java.util.ArrayList;
     
    8989        Random rand = new SecureRandom();
    9090        try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
    91                 new FileOutputStream(PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) {
     91                Files.newOutputStream(Paths.get(PROJECTION_DATA_FILE)), StandardCharsets.UTF_8))) {
    9292            out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n");
    9393            out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n");
     
    114114
    115115    private static List<TestData> readData() throws IOException, FileNotFoundException {
    116         try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(PROJECTION_DATA_FILE),
     116        try (BufferedReader in = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(PROJECTION_DATA_FILE)),
    117117                StandardCharsets.UTF_8))) {
    118118            List<TestData> result = new ArrayList<>();
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java

    r8926 r15034  
    55import static org.junit.Assert.assertThat;
    66
    7 import java.io.FileInputStream;
    87import java.io.FileNotFoundException;
    98import java.io.IOException;
    109import java.io.InputStream;
     10import java.nio.file.Files;
     11import java.nio.file.Paths;
    1112
    1213import org.junit.Before;
     
    4546    @Test
    4647    public void testTicket6313() throws IOException, IllegalDataException, FileNotFoundException {
    47         try (InputStream fis = new FileInputStream("data_nodist/UnconnectedWaysTest.osm")) {
     48        try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/UnconnectedWaysTest.osm"))) {
    4849            final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    4950            bib.visit(ds.allPrimitives());
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ValidatorTestUtils.java

    r14966 r15034  
    66import static org.junit.Assert.fail;
    77
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.ArrayList;
    1112import java.util.Collections;
     
    3536            Function<DataSet, Iterable<T>> provider, Predicate<String> namePredicate,
    3637            Test... tests) throws Exception {
    37         try (InputStream is = new FileInputStream(sampleFile)) {
     38        try (InputStream is = Files.newInputStream(Paths.get(sampleFile))) {
    3839            for (T t: provider.apply(OsmReader.parseDataSet(is, null))) {
    3940                String name = DefaultNameFormatter.getInstance().format(t);
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    r10876 r15034  
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
    33
    4 import java.io.FileInputStream;
    54import java.io.IOException;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.List;
    89
     
    4445    public void loadData() throws IllegalDataException, IOException {
    4546        if (testDataset == null) {
    46             try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {
     47            try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) {
    4748                testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    4849            }
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    r11886 r15034  
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
    33
    4 import java.io.FileInputStream;
    54import java.io.IOException;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.ArrayList;
    89import java.util.Arrays;
     
    4647    public void loadData() throws IllegalDataException, IOException {
    4748        if (testDataset == null) {
    48             try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {
     49            try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) {
    4950                testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    5051            }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java

    r14064 r15034  
    66import static org.junit.Assert.assertTrue;
    77
    8 import java.io.FileInputStream;
     8import java.nio.file.Files;
     9import java.nio.file.Paths;
    910import java.util.Arrays;
    1011
     
    188189    @Test
    189190    public void testContains() throws Exception {
    190         ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/amenity-in-amenity.osm"), null);
     191        ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get("data_nodist/amenity-in-amenity.osm")), null);
    191192        ChildOrParentSelector css = parse("node[tag(\"amenity\") = parent_tag(\"amenity\")] ∈ *[amenity] {}");
    192193        assertTrue(css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.WAY))));
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java

    r13232 r15034  
    55import static org.junit.Assert.assertTrue;
    66
    7 import java.io.FileInputStream;
     7import java.io.InputStream;
     8import java.nio.file.Files;
     9import java.nio.file.Paths;
    810import java.util.Arrays;
    911
     
    113115    @Test
    114116    public void testMultipolygon() throws Exception {
    115         try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {
     117        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) {
    116118            DataSet ds = OsmReader.parseDataSet(in, null);
    117119            final GeoJSONWriter writer = new GeoJSONWriter(ds);
     
    126128    @Test
    127129    public void testMultipolygonRobustness() throws Exception {
    128         try (FileInputStream in = new FileInputStream("data_nodist/multipolygon.osm")) {
     130        try (InputStream in = Files.newInputStream(Paths.get("data_nodist/multipolygon.osm"))) {
    129131            DataSet ds = OsmReader.parseDataSet(in, null);
    130132            final GeoJSONWriter writer = new GeoJSONWriter(ds);
  • trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java

    r14219 r15034  
    99
    1010import java.io.ByteArrayInputStream;
    11 import java.io.FileInputStream;
    1211import java.io.InputStream;
    1312import java.nio.charset.StandardCharsets;
     13import java.nio.file.Files;
     14import java.nio.file.Paths;
    1415
    1516import org.junit.Rule;
     
    5960        OsmReader.deregisterPostprocessor(unregistered);
    6061
    61         try (InputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "empty.osm")) {
     62        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "empty.osm"))) {
    6263            OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
    6364            assertTrue(registered.called);
  • trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java

    r14456 r15034  
    77
    88import java.io.ByteArrayInputStream;
    9 import java.io.FileInputStream;
    109import java.io.IOException;
    1110import java.nio.charset.StandardCharsets;
     11import java.nio.file.Files;
     12import java.nio.file.Paths;
    1213import java.text.SimpleDateFormat;
    1314import java.util.ArrayList;
     
    6162    public void testReader() throws Exception {
    6263        TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
    63         final NmeaReader in = new NmeaReader(new FileInputStream("data_nodist/btnmeatrack_2016-01-25.nmea"));
     64        final NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get("data_nodist/btnmeatrack_2016-01-25.nmea")));
    6465        in.parse(true);
    6566        assertEquals(30, in.getNumberOfCoordinates());
     
    8788    private static void compareWithReference(int ticket, String filename, int numCoor) throws IOException, SAXException {
    8889        GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(ticket, filename+".gpx"));
    89         NmeaReader in = new NmeaReader(new FileInputStream(TestUtils.getRegressionDataFile(ticket, filename+".nmea")));
     90        NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(ticket, filename+".nmea"))));
    9091        in.parse(true);
    9192        assertEquals(numCoor, in.getNumberOfCoordinates());
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r15022 r15034  
    77import static org.junit.Assert.assertTrue;
    88
    9 import java.io.FileInputStream;
     9import java.io.InputStream;
     10import java.nio.file.Files;
     11import java.nio.file.Paths;
    1012import java.util.Arrays;
    1113import java.util.List;
     
    7880    @Test
    7981    public void testClosedWayArea() throws Exception {
    80         try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) {
     82        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) {
    8183            DataSet ds = OsmReader.parseDataSet(in, null);
    8284            Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
     
    9496    @Test
    9597    public void testMultipolygonArea() throws Exception {
    96         try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {
     98        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) {
    9799            DataSet ds = OsmReader.parseDataSet(in, null);
    98100            final Relation r = ds.getRelations().iterator().next();
     
    109111    @Test
    110112    public void testAreaAndPerimeter() throws Exception {
    111         try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) {
     113        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) {
    112114            DataSet ds = OsmReader.parseDataSet(in, null);
    113115            Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
Note: See TracChangeset for help on using the changeset viewer.