Changeset 6421 in josm for trunk/test


Ignore:
Timestamp:
2013-11-28T23:33:10+01:00 (6 years ago)
Author:
simon04
Message:

see #9341 - provide utility methods to open URL + decompress stream if needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r6410 r6421  
    44import org.junit.Assert;
    55import org.junit.Test;
     6import org.openstreetmap.josm.Main;
     7import org.openstreetmap.josm.data.Preferences;
     8
     9import java.io.BufferedReader;
     10import java.net.URL;
    611
    712/**
     
    6671        Assert.assertEquals("fedc", Utils.toHexString(new byte[]{(byte) 0xfe, (byte) 0xdc}));
    6772    }
     73
     74    @Test
     75    public void testOpenUrlGzip() throws Exception {
     76        Main.pref = new Preferences();
     77        final BufferedReader x = Utils.openURLReaderAndDecompress(new URL("http://www.openstreetmap.org/trace/1613906/data"), true);
     78        Assert.assertTrue(x.readLine().startsWith("<?xml version="));
     79        x.close();
     80    }
     81
     82    @Test
     83    public void testOpenUrlBzip() throws Exception {
     84        Main.pref = new Preferences();
     85        final BufferedReader x = Utils.openURLReaderAndDecompress(new URL("http://www.openstreetmap.org/trace/785544/data"), true);
     86        Assert.assertTrue(x.readLine().startsWith("<?xml version="));
     87        x.close();
     88    }
    6889}
Note: See TracChangeset for help on using the changeset viewer.