Changeset 9713 in josm


Ignore:
Timestamp:
2016-02-02T19:48:18+01:00 (9 years ago)
Author:
simon04
Message:

see #12437 see #12474 - Add (failing) unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/ImageryInfoTest.java

    r9007 r9713  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.util.Arrays;
     7import java.util.Collections;
     8import java.util.List;
     9import java.util.Map;
     10
    611import org.junit.BeforeClass;
    712import org.junit.Test;
    813import org.openstreetmap.josm.JOSMFixture;
     14import org.openstreetmap.josm.data.Preferences;
    915
    1016/**
     
    3339        assertEquals("tms[16,23]:http://localhost", testImageryTMS.getExtendedUrl());
    3440    }
     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    }
    3575}
Note: See TracChangeset for help on using the changeset viewer.