Changeset 13742 in josm


Ignore:
Timestamp:
2018-05-13T09:15:34+02:00 (6 years ago)
Author:
wiktorn
Message:

Checkstyle fixes

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java

    r13732 r13742  
    117117     * @param reader XMLStreamReader that should point to start of element
    118118     * @return content of current tag
    119      * @throws XMLStreamException
     119     * @throws XMLStreamException if any XML stream error occurs
    120120     */
    121121    public static String getElementTextWithSubtags(XMLStreamReader reader) throws XMLStreamException {
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r13733 r13742  
    14321432    /**
    14331433     * Sets custom HTTP headers that should be sent with request towards imagery provider
    1434      * @param customHttpHeaders
     1434     * @param customHttpHeaders http headers
    14351435     */
    14361436    public void setCustomHttpHeaders(Map<String, String> customHttpHeaders) {
     
    14621462    /**
    14631463     * Sets minimum tile expiration in seconds
    1464      * @param minimumTileExpire
     1464     * @param minimumTileExpire minimum tile expiration in seconds
    14651465     */
    14661466    public void setMinimumTileExpire(int minimumTileExpire) {
  • trunk/src/org/openstreetmap/josm/data/imagery/LayerDetails.java

    r13733 r13742  
    3838     * This is needed to properly handle layer attributes inheritance.
    3939     *
    40      * @param parentLayer
     40     * @param parentLayer parent layer
    4141     */
    4242    public LayerDetails(LayerDetails parentLayer) {
     
    7070
    7171    /**
     72     * @return title "Human readable" title of this layer
    7273     * @see LayerDetails#getName()
    73      * @return title "Human readable" title of this layer
    7474     */
    7575    public String getTitle() {
     
    7878
    7979    /**
     80     * @param title set title of this layer
    8081     * @see LayerDetails#getName()
    81      * @param title set title of this layer
    8282     */
    8383    public void setTitle(String title) {
     
    8888     *
    8989     * Citation from OGC WMS specification (WMS 1.3.0):
    90      * > A number of elements have both a <Name> and a <Title>. The Name is a text string used for machine-to-machine
     90     * > A number of elements have both a {@literal <Name>} and a {@literal <Title>}. The Name is a text string used for machine-to-machine
    9191     * > communication while the Title is for the benefit of humans. For example, a dataset might have the descriptive Title
    9292     * > “Maximum Atmospheric Temperature” and be requested using the abbreviated Name “ATMAX”.
    9393     *
    9494     * And second citation:
    95      * > If, and only if, a layer has a <Name>, then it is a map layer that can be requested by using that Name in the
    96      * > LAYERS parameter of a GetMap request. A Layer that contains a <Name> element is referred to as a “named
     95     * > If, and only if, a layer has a {@literal <Name>}, then it is a map layer that can be requested by using that Name in the
     96     * > LAYERS parameter of a GetMap request. A Layer that contains a {@literal <Name>} element is referred to as a “named
    9797     * > layer” in this International Standard. If the layer has a Title but no Name, then that layer is only a category title for
    9898     * > all the layers nested within.
     
    104104
    105105    /**
     106     * @param name sets the name of this Layer
    106107     * @see LayerDetails#getName()
    107      * @param name sets the name of this Layer
    108108     */
    109109    public void setName(String name) {
     
    138138    /**
    139139     * sets bounds of this layer
    140      * @param bounds
     140     * @param bounds of this layer
    141141     */
    142142    public void setBounds(Bounds bounds) {
     
    160160    /**
    161161     * sets children layers for this layer
    162      * @param children
     162     * @param children children of this layer
    163163     */
    164164    public void setChildren(List<LayerDetails> children) {
     
    192192    /**
    193193     * Sets abstract of this layer
    194      * @param abstr
     194     * @param abstr abstract of this layer
    195195     */
    196196    public void setAbstract(String abstr) {
  • trunk/src/org/openstreetmap/josm/data/imagery/TileJobOptions.java

    r13733 r13742  
    2323     * @param connectTimeout in milliseconds
    2424     * @param readTimeout in milliseconds
    25      * @param headers
     25     * @param headers http headers
    2626     * @param minimumExpiryTime in seconds
    2727     */
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSEndpointTileSource.java

    r13733 r13742  
    3131    private List<DefaultLayer> layers;
    3232    private String urlPattern;
    33     private static final Pattern PATTERN_PARAM  = Pattern.compile("\\{([^}]+)\\}");
     33    private static final Pattern PATTERN_PARAM = Pattern.compile("\\{([^}]+)\\}");
    3434    private final Map<String, String> headers = new ConcurrentHashMap<>();
    3535
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13740 r13742  
    303303     * @param info imagery info
    304304     * @throws IOException if any I/O error occurs
    305      * @throws WMTSGetCapabilitiesException
     305     * @throws WMTSGetCapabilitiesException when document didn't contain any layers
    306306     * @throws IllegalArgumentException if any other error happens for the given imagery info
    307307     */
     
    312312        this.baseUrl = GetCapabilitiesParseHelper.normalizeCapabilitiesUrl(handleTemplate(info.getUrl()));
    313313        WMTSCapabilities capabilities = getCapabilities(baseUrl, headers);
    314         this.layers =  capabilities.getLayers();
     314        this.layers = capabilities.getLayers();
    315315        this.baseUrl = capabilities.getBaseUrl();
    316316        this.transferMode = capabilities.getTransferMode();
     
    374374     * @return capabilities
    375375     * @throws IOException in case of any I/O error
    376      * @throws WMTSGetCapabilitiesException
     376     * @throws WMTSGetCapabilitiesException when document didn't contain any layers
    377377     * @throws IllegalArgumentException in case of any other error
    378378     */
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r13733 r13742  
    6666    public WMSLayer(ImageryInfo info) {
    6767        super(info);
    68         CheckParameterUtil.ensureThat(info.getImageryType() == ImageryType.WMS || info.getImageryType() == ImageryType.WMS_ENDPOINT, "ImageryType is WMS");
     68        CheckParameterUtil.ensureThat(
     69                info.getImageryType() == ImageryType.WMS || info.getImageryType() == ImageryType.WMS_ENDPOINT, "ImageryType is WMS");
    6970        CheckParameterUtil.ensureParameterNotNull(info.getUrl(), "info.url");
    7071        if (info.getImageryType() == ImageryType.WMS) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddImageryPanel.java

    r13734 r13742  
    4848    protected final transient Collection<ContentValidationListener> listeners = new ArrayList<>();
    4949
    50     private final JCheckBox validGeoreference= new JCheckBox(tr("Is layer properly georeferenced?"));
     50    private final JCheckBox validGeoreference = new JCheckBox(tr("Is layer properly georeferenced?"));
    5151    private HeadersTable headersTable;
    5252    private JSpinner minimumCacheExpiry;
     
    7272        headersTable = new HeadersTable();
    7373        minimumCacheExpiry = new JSpinner(new SpinnerNumberModel(
    74                 (Number)TimeUnit.MILLISECONDS.toSeconds(TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get()),
     74                (Number) TimeUnit.MILLISECONDS.toSeconds(TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get()),
    7575                0L,
    7676                Long.valueOf(Integer.MAX_VALUE),
     
    101101                    break;
    102102                default:
    103                     Logging.warn("Dupa: " + units.indexOf(e.getItem()));
     103                    Logging.warn("Unkown unit: " + units.indexOf(e.getItem()));
    104104                }
    105105                minimumCacheExpiry.setValue(newValue);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java

    r13741 r13742  
    100100            Layer selectedLayer = layers.get(layerTable.convertRowIndexToModel(index)).getValue().get(0);
    101101            ret.setDefaultLayers(
    102                     Collections.<DefaultLayer> singletonList(
     102                    Collections.<DefaultLayer>singletonList(
    103103                            new DefaultLayer(
    104104                                    ImageryType.WMTS,
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/HeadersTable.java

    r13733 r13742  
    7272
    7373            } else if (row == headers.size()) {
    74                 String[] entry = new String[] { "", "" };
     74                String[] entry = new String[] {"", ""};
    7575                entry[col] = (String) value;
    7676                headers.add(entry);
     
    9393    /**
    9494     * Create table prefilled with headers
    95      * @param headers
     95     * @param headers contents of table
    9696     */
    9797    public HeadersTable(Map<String, String> headers) {
     
    108108    private static List<String[]> getHeadersAsVector(Map<String, String> headers) {
    109109        return headers.entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey()))
    110                 .map(e -> new String[] { e.getKey(), e.getValue() }).collect(Collectors.toList());
     110                .map(e -> new String[] {e.getKey(), e.getValue()}).collect(Collectors.toList());
    111111    }
    112112
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r13733 r13742  
    290290                if ("layer".equals(qName)) {
    291291                    newState = State.NOOP;
    292                     defaultLayers.add(new DefaultLayer(entry.getImageryType(), atts.getValue("name"),atts.getValue("style"), atts.getValue("tileMatrixSet")));
     292                    defaultLayers.add(new DefaultLayer(
     293                            entry.getImageryType(),
     294                            atts.getValue("name"),
     295                            atts.getValue("style"),
     296                            atts.getValue("tileMatrixSet")
     297                            ));
    293298                }
    294299                break;
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r13741 r13742  
    132132     * Make getCapabilities request towards given URL
    133133     * @param url service url
    134      * @throws IOException
    135      * @throws WMSGetCapabilitiesException
     134     * @throws IOException when connection error when fetching get capabilities document
     135     * @throws WMSGetCapabilitiesException when there are errors when parsing get capabilities document
    136136     */
    137137    public WMSImagery(String url) throws IOException, WMSGetCapabilitiesException {
     
    143143     * @param url service url
    144144     * @param headers HTTP headers to be sent with request
    145      * @throws IOException
    146      * @throws WMSGetCapabilitiesException
     145     * @throws IOException when connection error when fetching get capabilities document
     146     * @throws WMSGetCapabilitiesException when there are errors when parsing get capabilities document
    147147     */
    148148    public WMSImagery(String url, Map<String, String> headers) throws IOException, WMSGetCapabilitiesException {
     
    185185                } catch (MalformedURLException e1) { // NOPMD
    186186                    // do nothing, raise original exception
     187                    Logging.trace(e1);
    187188                }
    188189            }
     
    287288
    288289    /**
    289      * @see #buildGetMapUrl(List, boolean)
    290      *
    291290     * @param selectedLayers selected layers as subset of the tree returned by {@link #getLayers()}
    292291     * @param selectedStyles selected styles for all selectedLayers
    293292     * @param transparent whether returned images should contain transparent pixels (if supported by format)
    294293     * @return URL template for GetMap service
     294     * @see #buildGetMapUrl(List, boolean)
    295295     */
    296296    public String buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, boolean transparent) {
     
    303303
    304304    /**
    305      * @see #buildGetMapUrl(List, boolean)
    306      *
    307305     * @param selectedLayers selected layers as list of strings
    308306     * @param selectedStyles selected styles of layers as list of strings
     
    310308     * @param transparent whether returned images should contain transparent pixels (if supported by format)
    311309     * @return URL template for GetMap service
     310     * @see #buildGetMapUrl(List, boolean)
    312311     */
    313312    public String buildGetMapUrl(List<String> selectedLayers,
     
    385384        if (GetCapabilitiesParseHelper.moveReaderToTag(reader, this::tagEquals, QN_TITLE)) {
    386385            this.title = reader.getElementText();
     386            // CHECKSTYLE.OFF: EmptyBlock
    387387            for (int event = reader.getEventType();
    388388                    reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT && tagEquals(QN_SERVICE, reader.getName()));
     
    390390                // empty loop, just move reader to the end of Service tag, if moveReaderToTag return false, it's already done
    391391            }
     392            // CHECKSTYLE.ON: EmptyBlock
    392393        }
    393394    }
     
    591592    }
    592593
    593 
    594594    private String normalizeUrl(String serviceUrlStr) throws MalformedURLException {
    595595        URL getCapabilitiesUrl = null;
     
    641641    }
    642642
    643 
    644643    static boolean imageFormatHasTransparency(final String format) {
    645644        return format != null && (format.startsWith("image/png") || format.startsWith("image/gif")
     
    686685
    687686    /**
    688      * @param defaultLayers
     687     * @param defaultLayers default layers that should select layer object
    689688     * @return collection of LayerDetails specified by DefaultLayers
    690689     */
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r13733 r13742  
    411411                    );
    412412    }
     413
    413414    /**
    414415     * Renders Temporal to RFC 1123 Date Time
    415      * @param time
     416     * @param time to convert
    416417     * @return string representation according to RFC1123 of time
    417418     */
     
    422423    /**
    423424     * Renders java time stamp to RFC 1123 Date Time
    424      * @param time
     425     * @param time java timestamp (milliseconds from Epoch)
    425426     * @return string representation according to RFC1123 of time
    426427     */
     
    428429        return getHTTPDate(Instant.ofEpochMilli(time));
    429430    }
    430 
    431 
    432431}
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java

    r13733 r13742  
    4747        private String key;
    4848
    49         TestCachedTileLoaderJob(String url, String key)  {
     49        TestCachedTileLoaderJob(String url, String key) {
    5050            this(url, key, (int) TimeUnit.DAYS.toSeconds(1));
    5151        }
    5252
    53         TestCachedTileLoaderJob(String url, String key, int minimumExpiry)  {
     53        TestCachedTileLoaderJob(String url, String key, int minimumExpiry) {
    5454            super(getCache(), new TileJobOptions(30000, 30000, null, minimumExpiry));
    5555
     
    5757            this.key = key;
    5858        }
    59 
    6059
    6160        @Override
     
    183182
    184183    /**
    185      * That no requst is made when entry is in cache and force == false
    186      * @throws IOException
     184     * That no request is made when entry is in cache and force == false
     185     * @throws IOException exception
    187186     */
    188187    @Test
     
    205204    /**
    206205     * that request is made, when object is in cache, but force mode is used
    207      * @throws IOException
     206     * @throws IOException exception
    208207     */
    209208    @Test
    210209    public void testRequestMadeWhenEntryInCacheAndForce() throws IOException {
    211210        ICacheAccess<String, CacheEntry> cache = getCache();
    212         long expires =  TimeUnit.DAYS.toMillis(1);
     211        long expires = TimeUnit.DAYS.toMillis(1);
    213212        long testStart = System.currentTimeMillis();
    214213        cache.put("test",
     
    227226     * Mock returns no cache-control / expires headers
    228227     * Expire time should be set to DEFAULT_EXPIRE_TIME
    229      * @throws IOException
     228     * @throws IOException exception
    230229     */
    231230    @Test
     
    247246                listener.attributes.getExpirationTime() >= testStart + JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME);
    248247
    249         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - System.currentTimeMillis()) + " which is not less than " +
     248        assertTrue("Cache entry expiration is " +
     249                (listener.attributes.getExpirationTime() - System.currentTimeMillis()) +
     250                " which is not less than " +
    250251                JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME + " (DEFAULT_EXPIRE_TIME)",
    251                 listener.attributes.getExpirationTime() <= System.currentTimeMillis() + JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME);
     252                listener.attributes.getExpirationTime() <= System.currentTimeMillis() + JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME
     253                );
    252254
    253255        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
     
    257259     * Mock returns expires headers, but Cache-Control
    258260     * Expire time should be set to max-age
    259      * @throws IOException
     261     * @throws IOException exception
    260262     */
    261263    @Test
    262264    public void testSettingExpireByMaxAge() throws IOException {
    263265        long testStart = System.currentTimeMillis();
    264         long expires =  TimeUnit.DAYS.toSeconds(1);
     266        long expires = TimeUnit.DAYS.toSeconds(1);
    265267        tileServer.stubFor(
    266268                WireMock.get(WireMock.urlEqualTo("/test"))
     
    279281                listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(expires));
    280282
    281         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - System.currentTimeMillis()) + " which is not less than " +
     283        assertTrue("Cache entry expiration is " +
     284                (listener.attributes.getExpirationTime() - System.currentTimeMillis()) +
     285                " which is not less than " +
    282286                TimeUnit.SECONDS.toMillis(expires) + " (max-age)",
    283                 listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(expires));
     287                listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(expires)
     288                );
    284289
    285290        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
     
    289294     * mock returns expiration: JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10
    290295     * minimum expire time: JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 2
    291      * @throws IOException
     296     * @throws IOException exception
    292297     */
    293298    @Test
    294299    public void testSettingMinimumExpiryByMinimumExpiryTimeLessThanDefault() throws IOException {
    295300        long testStart = System.currentTimeMillis();
    296         int minimumExpiryTimeSeconds = (int)(JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 2);
     301        int minimumExpiryTimeSeconds = (int) (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 2);
    297302
    298303        createHeadGetStub(WireMock.urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
     
    306311        assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - testStart) + " which is not larger than " +
    307312                TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) + " (minimumExpireTime)",
    308                 listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) );
    309 
    310         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - System.currentTimeMillis()) + " which is not less than " +
     313                listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds));
     314
     315        assertTrue("Cache entry expiration is " +
     316                (listener.attributes.getExpirationTime() - System.currentTimeMillis()) +
     317                " which is not less than " +
    311318                TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) + " (minimumExpireTime)",
    312                 listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds));
     319                listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds)
     320                );
    313321    }
    314322
     
    316324     * mock returns expiration: JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10
    317325     * minimum expire time: JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME * 2
    318      * @throws IOException
     326     * @throws IOException exception
    319327     */
    320328
     
    322330    public void testSettingMinimumExpiryByMinimumExpiryTimeGreaterThanDefault() throws IOException {
    323331        long testStart = System.currentTimeMillis();
    324         int minimumExpiryTimeSeconds = (int)(JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME * 2);
     332        int minimumExpiryTimeSeconds = (int) (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME * 2);
    325333
    326334        createHeadGetStub(WireMock.urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
     
    334342        assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - testStart) + " which is not larger than " +
    335343                TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) + " (minimumExpireTime)",
    336                 listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) );
    337 
    338         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - System.currentTimeMillis()) + " which is not less than " +
     344                listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds));
     345
     346        assertTrue("Cache entry expiration is " +
     347                (listener.attributes.getExpirationTime() - System.currentTimeMillis()) +
     348                " which is not less than " +
    339349                TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds) + " (minimumExpireTime)",
    340                 listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds));
     350                listener.attributes.getExpirationTime() <= System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(minimumExpiryTimeSeconds)
     351                );
    341352    }
    342353
    343354    /**
    344355     * Check if verifying cache entries using HEAD requests work properly
    345      * @throws IOException
     356     * @throws IOException exception
    346357     */
    347358    @Test
     
    385396        // invalidate entry in cache
    386397        ICacheElement<String, CacheEntry> cacheEntry = cache.getCacheElement("test");
    387         CacheEntryAttributes attributes = (CacheEntryAttributes)cacheEntry.getElementAttributes();
     398        CacheEntryAttributes attributes = (CacheEntryAttributes) cacheEntry.getElementAttributes();
    388399        attributes.setExpirationTime(testStart - TimeUnit.DAYS.toMillis(1));
    389400        cache.put("test", cacheEntry.getVal(), attributes);
     
    406417    /**
    407418     * Check if server returns 304 - it will update cache attributes and not ask again for it
    408      * @throws IOException
     419     * @throws IOException exception
    409420     */
    410421    @Test
     
    470481    }
    471482
    472     private static TestCachedTileLoaderJob getStatusLoaderJob(int responseCode)  {
     483    private static TestCachedTileLoaderJob getStatusLoaderJob(int responseCode) {
    473484        return new TestCachedTileLoaderJob("http://httpstat.us/" + responseCode, "key_" + responseCode);
    474485    }
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java

    r13733 r13742  
    6868        private String key;
    6969
    70         TestCachedTileLoaderJob(TileLoaderListener listener, Tile tile, String key) throws IOException  {
    71             this(listener, tile, key,  (int) TimeUnit.DAYS.toSeconds(1));
    72         }
    73 
    74         TestCachedTileLoaderJob(TileLoaderListener listener, Tile tile, String key, int minimumExpiry) throws IOException  {
     70        TestCachedTileLoaderJob(TileLoaderListener listener, Tile tile, String key) throws IOException {
     71            this(listener, tile, key, (int) TimeUnit.DAYS.toSeconds(1));
     72        }
     73
     74        TestCachedTileLoaderJob(TileLoaderListener listener, Tile tile, String key, int minimumExpiry) throws IOException {
    7575            super(listener, tile, getCache(), new TileJobOptions(30000, 30000, null, minimumExpiry),
    7676                    (ThreadPoolExecutor) Executors.newFixedThreadPool(1));
     
    104104                return false;
    105105            }
    106             return cacheData.getContent().length > 0;        }
     106            return cacheData.getContent().length > 0;
     107        }
    107108    }
    108109
     
    112113        private byte[] data;
    113114
    114 
    115115        @Override
    116116        public synchronized void tileLoadingFinished(Tile tile, boolean success) {
     
    129129        private final String url;
    130130
    131         public MockTileSource(String url) {
     131        MockTileSource(String url) {
    132132            super(new ImageryInfo("mock"));
    133133            this.url = url;
     
    191191    /**
    192192     * When tile server doesn't return any Expires/Cache-Control headers, expire should be at least MINIMUM_EXPIRES
    193      * @throws IOException
     193     * @throws IOException exception
    194194     */
    195195    @Test
     
    214214    /**
    215215     * When tile server doesn't return any Expires/Cache-Control headers, expire should be at least minimumExpires parameter
    216      * @throws IOException
     216     * @throws IOException exception
    217217     */
    218218    @Test
     
    224224     * When tile server doesn't return any Expires/Cache-Control headers, expire should be at least minimumExpires parameter,
    225225     * which is larger than MAXIMUM_EXPIRES
    226      * @throws IOException
     226     * @throws IOException exception
    227227     */
    228228
     
    251251    /**
    252252     * When tile server returns Expires header shorter than MINIMUM_EXPIRES, we should cache if for at least MINIMUM_EXPIRES
    253      * @throws IOException
     253     * @throws IOException exception
    254254     */
    255255    @Test
     
    288288                job.getAttributes().getExpirationTime() <= duration);
    289289    }
    290 
    291290
    292291    @Test
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r13735 r13742  
    5353                "<type>wms_endpoint</type>\n" +
    5454                "<url><![CDATA[" + tileServer.url("/capabilities") + "]]></url>\n" +
    55                 "<icon>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAAB5UlEQVQ4y4WTwWsTURDGfy8W1yYmXZOqtGJJFyGw6KF7CEigwYuS0kthrYUi4i0iORS9BU9hQdA/ILcixVBrwENKLz1FUBB0wWOwYFAqxUNYTZq6BfM8yC5d05iBObz3vfnmm3kz4sqDh/zP7szdlG5I+Of1zQ1xFA8xxI4GH2cjg4Cl+UUJcC4SJq6c7FPkKRlIoPQk0+NnuDwxHrhvuYd83+8OVuBlHouE/eDXzW8+/qO9DyHB0vyiVHoy2INSNiPdeg23XuPs3icmIoofPKXGmFJjjEUjgf4EFNi2TT6fJ5FI0Gg0ePrkMRfnbvn41QsJgEAJAQUdbYZyuQxAcvoSpmnydesFAF+cn8f2KUCw/fGt6GgzWJbF706bVCoFwGxyktnk5N8kB79QepL1zQ3xbOulCJWyGbkQHZWlbEZ6JIZhBDI1nQ5Np8P2zi4t9zAwGyNe3QALti11XSedTvsPYrEY73f3Bk+irusAnI6qrNy7z43sNUbFCQC6LYdCoYBbr/k1/2sh690HUalUaH7eIRxXA+6RFItF3HqN6+dP9REIb5lK2Yy0bdsHDMMgl8vRbTkAhOMqlmVhmibLq2ui7xsf1d+IV+0D3zVNw7KsPiXVapXnd2/Lodu4vLomTNMcSvIHY6bDkqJtEqIAAAAASUVORK5CYII=</icon>\n" +
     55                "<icon>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAAB5UlEQVQ4y4WTwWsTURDG" +
     56                "fy8W1yYmXZOqtGJJFyGw6KF7CEigwYuS0kthrYUi4i0iORS9BU9hQdA/ILcixVBrwENKLz1FUBB0wWOwYFAqxUNYTZq6BfM8yC5d05iBObz3vfnmm3kz4sqDh/zP" +
     57                "7szdlG5I+Of1zQ1xFA8xxI4GH2cjg4Cl+UUJcC4SJq6c7FPkKRlIoPQk0+NnuDwxHrhvuYd83+8OVuBlHouE/eDXzW8+/qO9DyHB0vyiVHoy2INSNiPdeg23XuPs" +
     58                "3icmIoofPKXGmFJjjEUjgf4EFNi2TT6fJ5FI0Gg0ePrkMRfnbvn41QsJgEAJAQUdbYZyuQxAcvoSpmnydesFAF+cn8f2KUCw/fGt6GgzWJbF706bVCoFwGxyktnk" +
     59                "5N8kB79QepL1zQ3xbOulCJWyGbkQHZWlbEZ6JIZhBDI1nQ5Np8P2zi4t9zAwGyNe3QALti11XSedTvsPYrEY73f3Bk+irusAnI6qrNy7z43sNUbFCQC6LYdCoYBb" +
     60                "r/k1/2sh690HUalUaH7eIRxXA+6RFItF3HqN6+dP9REIb5lK2Yy0bdsHDMMgl8vRbTkAhOMqlmVhmibLq2ui7xsf1d+IV+0D3zVNw7KsPiXVapXnd2/Lodu4vLom" +
     61                "TNMcSvIHY6bDkqJtEqIAAAAASUVORK5CYII=</icon>\n" +
    5662                "<attribution-text mandatory=\"true\">© Geofabrik GmbH, OpenStreetMap contributors, CC-BY-SA</attribution-text>\n" +
    5763                "<attribution-url>http://tools.geofabrik.de/osmi/</attribution-url>\n" +
     
    7278        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
    7379        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
    74         assertEquals("https://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&"
    75                 + "LAYERS=single_node_in_way&STYLES=default&"
     80        assertEquals("https://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&"
     81                + "REQUEST=GetMap&LAYERS=single_node_in_way&STYLES=default&"
    7682                + "SRS=EPSG:3857&WIDTH=512&HEIGHT=512&"
    7783                + "BBOX=20037506.6204108,-60112521.5836107,60112521.5836107,-20037506.6204108", tileSource.getTileUrl(1, 1, 1));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r13735 r13742  
    4646    @ClassRule
    4747    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    48     public static JOSMTestRules test = new JOSMTestRules().preferences().platform().projection().timeout((int)TimeUnit.MINUTES.toMillis(5));
     48    public static JOSMTestRules test = new JOSMTestRules().preferences().platform().projection().timeout((int) TimeUnit.MINUTES.toMillis(5));
    4949
    5050    @Rule
     
    6767            "wmts/bug13975-multiple-tile-matrices-for-one-layer-projection.xml");
    6868
    69 
    7069    private static ImageryInfo getImagery(String path) {
    7170        try {
     
    259258        testSource.initProjection(Main.getProjection());
    260259        assertEquals(
    261                 "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/default028mm/4/2932/2371.jpg",
     260                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     261                + "default028mm/4/2932/2371.jpg",
    262262                testSource.getTileUrl(4, 2371, 2932));
    263263        verifyTile(new LatLon(45.4601306, -75.7617187), testSource, 2372, 2932, 4);
     
    275275        testSource.initProjection(Main.getProjection());
    276276        assertEquals(
    277                 "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/GoogleMapsCompatible/4/2932/2371.jpg",
     277                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     278                + "GoogleMapsCompatible/4/2932/2371.jpg",
    278279                testSource.getTileUrl(4, 2371, 2932));
    279280        verifyMercatorTile(testSource, 74, 91, 8);
     
    326327     * Test WMTS dimension.
    327328     * @throws IOException if any I/O error occurs
    328      * @throws WMTSGetCapabilitiesException
     329     * @throws WMTSGetCapabilitiesException if any error occurs
    329330     */
    330331    @Test
  • trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java

    r13735 r13742  
    8686        tileServer.stubFor(
    8787                WireMock.get(WireMock.anyUrl())
    88                 .willReturn(WireMock.aResponse().withBody(Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml"))))));
     88                .willReturn(WireMock.aResponse().withBody(
     89                        Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml")))
     90                        ))
     91                );
    8992        WMSImagery wms = new WMSImagery(tileServer.url("any"));
    9093        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k", wms.buildRootUrl());
     
    9295        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25kFORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&"
    9396                + "LAYERS=wms.hgis.cartomatic.pl&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}",
    94                 wms.buildGetMapUrl(wms.getLayers(), (List<String>)null, true));
     97                wms.buildGetMapUrl(wms.getLayers(), (List<String>) null, true));
    9598    }
    9699}
Note: See TracChangeset for help on using the changeset viewer.