Changeset 18806 in josm for trunk/test/unit


Ignore:
Timestamp:
2023-08-14T17:56:25+02:00 (9 months ago)
Author:
taylor.smock
Message:

Fix #23119: NPE in RemoteEntry.getLastModified

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/RemoteEntryTest.java

    r18635 r18806  
    22package org.openstreetmap.josm.gui.layer.geoimage;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5
     6import java.io.File;
    47import java.net.URI;
    58import java.util.Objects;
     
    811import nl.jqno.equalsverifier.EqualsVerifier;
    912import org.junit.jupiter.api.Test;
     13import org.openstreetmap.josm.TestUtils;
    1014
    1115/**
     
    1317 */
    1418class RemoteEntryTest {
     19    private static final Supplier<RemoteEntry> NULL_SUPPLIER = () -> null;
    1520    @Test
    1621    void testHashCodeEquals() {
    17         RemoteEntry remoteEntryA = new RemoteEntry(URI.create("https://somewhere.com/image.png?hash=a"),
    18                 () -> null, () -> null, () -> null, () -> null);
    19         RemoteEntry remoteEntryB = new RemoteEntry(URI.create("https://somewhere.com/image.png?hash=b"),
    20                 () -> null, () -> null, () -> null, () -> null);
     22        final RemoteEntry remoteEntryA = new RemoteEntry(URI.create("https://somewhere.com/image.png?hash=a"),
     23                NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER);
     24        final RemoteEntry remoteEntryB = new RemoteEntry(URI.create("https://somewhere.com/image.png?hash=b"),
     25                NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER);
    2126        EqualsVerifier.simple().forClass(RemoteEntry.class).usingGetClass()
    2227                .withIgnoredFields("firstImage", "lastImage", "nextImage", "previousImage" /* These suppliers don't have good == semantics */,
     
    2631                .withGenericPrefabValues(Supplier.class,
    2732                        a -> () -> new RemoteEntry(URI.create("https://somewhere.com/image.png?hash=" + Objects.hash(a)),
    28                                 () -> null, () -> null, () -> null, () -> null)).verify();
     33                                NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER)).verify();
     34    }
     35
     36    @Test
     37    void testNonRegression23119() {
     38        final String fileLocation = TestUtils.getRegressionDataFile(11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg");
     39        final RemoteEntry remoteEntry = new RemoteEntry(new File(fileLocation).toURI(),
     40                NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER, NULL_SUPPLIER);
     41        assertDoesNotThrow(remoteEntry::getLastModified);
    2942    }
    3043}
Note: See TracChangeset for help on using the changeset viewer.