Changeset 9713 in josm
- Timestamp:
- 2016-02-02T19:48:18+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/ImageryInfoTest.java
r9007 r9713 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.util.Arrays; 7 import java.util.Collections; 8 import java.util.List; 9 import java.util.Map; 10 6 11 import org.junit.BeforeClass; 7 12 import org.junit.Test; 8 13 import org.openstreetmap.josm.JOSMFixture; 14 import org.openstreetmap.josm.data.Preferences; 9 15 10 16 /** … … 33 39 assertEquals("tms[16,23]:http://localhost", testImageryTMS.getExtendedUrl()); 34 40 } 41 42 /** 43 * Tests the {@linkplain Preferences#serializeStruct(Object, Class) serialization} of {@link ImageryInfo.ImageryPreferenceEntry} 44 */ 45 @Test 46 public void testSerializeStruct() { 47 final ImageryInfo.ImageryPreferenceEntry info = new ImageryInfo.ImageryPreferenceEntry(); 48 info.noTileHeaders = Collections.singletonMap("ETag", Arrays.asList("foo", "bar")); 49 final Map<String, String> map = Preferences.serializeStruct(info, ImageryInfo.ImageryPreferenceEntry.class); 50 assertEquals("{noTileHeaders={\"ETag\":[\"foo\",\"bar\"]}}", map.toString()); 51 } 52 53 /** 54 * Tests the {@linkplain Preferences#deserializeStruct(Map, Class)} deserialization} of {@link ImageryInfo.ImageryPreferenceEntry} 55 */ 56 @Test 57 public void testDeserializeStruct() { 58 final ImageryInfo.ImageryPreferenceEntry info = Preferences.deserializeStruct( 59 Collections.singletonMap("noTileHeaders", "{\"ETag\":[\"foo\",\"bar\"]}"), ImageryInfo.ImageryPreferenceEntry.class); 60 assertEquals(info.noTileHeaders, Collections.singletonMap("ETag", Arrays.asList("foo", "bar"))); 61 final List<String> eTag = info.noTileHeaders.get("ETag"); 62 assertEquals(eTag, Arrays.asList("foo", "bar")); 63 } 64 65 /** 66 * Tests the {@linkplain Preferences#deserializeStruct(Map, Class)} deserialization} of legacy {@link ImageryInfo.ImageryPreferenceEntry} 67 */ 68 @Test 69 public void testDeserializeStructTicket12474() { 70 final ImageryInfo.ImageryPreferenceEntry info = Preferences.deserializeStruct( 71 Collections.singletonMap("noTileHeaders", "{\"ETag\":\"foo-and-bar\"}"), ImageryInfo.ImageryPreferenceEntry.class); 72 final List<String> eTag = info.noTileHeaders.get("ETag"); 73 assertEquals(eTag, Arrays.asList("foo", "bar")); 74 } 35 75 }
Note:
See TracChangeset
for help on using the changeset viewer.