Ignore:
Timestamp:
2015-07-27T14:52:11+02:00 (10 years ago)
Author:
floscher
Message:

Don't throw an exception in MapillaryImportedImage.getImage() when file==null

Location:
applications/editors/josm/plugins/mapillary
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java

    r31390 r31410  
    6363   * Returns the pictures of the file.
    6464   *
    65    * @return A BufferedImage object containing the pictures.
     65   * @return A BufferedImage object containing the picture,
     66   *           or null if the {@link File} given in the constructor was null.
    6667   * @throws IOException
    67    * @throws IllegalArgumentException
    68    *           if file is currently set to null
    6968   */
    7069  public BufferedImage getImage() throws IOException {
    71     return ImageIO.read(file);
     70    return file == null ? null : ImageIO.read(file);
    7271  }
    7372
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportedImageTest.java

    r31348 r31410  
    11package org.openstreetmap.josm.plugins.mapillary;
    22
     3import static org.junit.Assert.assertEquals;
     4
     5import java.io.File;
    36import java.io.IOException;
     7
     8import javax.imageio.IIOException;
    49
    510import org.junit.Before;
     
    1318    }
    1419
    15     @Test(expected=IllegalArgumentException.class)
    16     public void testNullFile() throws IOException {
     20    @Test(expected=IIOException.class)
     21    public void testInvalidFiles() throws IOException {
    1722        MapillaryImportedImage img = new MapillaryImportedImage(0,0,0, null);
     23        assertEquals(null, img.getImage());
     24        assertEquals(null, img.getFile());
     25
     26        img = new MapillaryImportedImage(0, 0, 0, new File(""));
     27        assertEquals(new File(""), img.getFile());
    1828        img.getImage();
    1929    }
Note: See TracChangeset for help on using the changeset viewer.