source: josm/trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java@ 9274

Last change on this file since 9274 was 8509, checked in by Don-vip, 9 years ago

fix many checkstyle violations

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6
7import java.io.File;
8import java.text.DecimalFormat;
9import java.text.ParseException;
10import java.util.Calendar;
11import java.util.Date;
12import java.util.GregorianCalendar;
13
14import org.junit.Before;
15import org.junit.Test;
16import org.openstreetmap.josm.data.coor.LatLon;
17
18/**
19 * EXIF metadata extraction test
20 * @since 6209
21 */
22public class ExifReaderTest {
23
24 private File orientationSampleFile, directionSampleFile;
25
26 /**
27 * Setup test
28 */
29 @Before
30 public void setUp() {
31 directionSampleFile = new File("data_nodist/exif-example_direction.jpg");
32 orientationSampleFile = new File("data_nodist/exif-example_orientation=6.jpg");
33 }
34
35 /**
36 * Test time extraction
37 * @throws ParseException if {@link ExifReader#readTime} fails to parse date/time of sample file
38 */
39 @Test
40 public void testReadTime() throws ParseException {
41 Date date = ExifReader.readTime(directionSampleFile);
42 assertEquals(new GregorianCalendar(2010, Calendar.MAY, 15, 17, 12, 05).getTime(), date);
43 }
44
45 /**
46 * Test orientation extraction
47 */
48 @Test
49 public void testReadOrientation() {
50 Integer orientation = ExifReader.readOrientation(orientationSampleFile);
51 assertEquals(Integer.valueOf(6), orientation);
52 }
53
54 /**
55 * Test coordinates extraction
56 */
57 @Test
58 public void testReadLatLon() {
59 LatLon latlon = ExifReader.readLatLon(directionSampleFile);
60 assertNotNull(latlon);
61 DecimalFormat f = new DecimalFormat("00.0");
62 assertEquals("51°46'"+f.format(43.0)+"\"", LatLon.dms(latlon.lat()));
63 assertEquals("8°21'"+f.format(56.3)+"\"", LatLon.dms(latlon.lon()));
64 }
65
66 /**
67 * Test coordinates extraction
68 */
69 @Test
70 public void testReadDirection() {
71 Double direction = ExifReader.readDirection(directionSampleFile);
72 assertEquals(new Double(46.5), direction);
73 }
74}
Note: See TracBrowser for help on using the repository browser.