Changeset 10641 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-07-25T21:41:53+02:00 (8 years ago)
Author:
Don-vip
Message:

move unit tests from UtilsTest to HttpClientTest (should have been done in r9720)

File:
1 edited

Legend:

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

    r10638 r10641  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.io.BufferedReader;
    7 import java.io.IOException;
    8 import java.net.URL;
    96import java.util.Arrays;
    107import java.util.Collections;
     
    1411import org.junit.Assert;
    1512import org.junit.Test;
    16 import org.openstreetmap.josm.Main;
    1713import org.openstreetmap.josm.testutils.JOSMTestRules;
    1814
     
    8783        Assert.assertEquals("127f", Utils.toHexString(new byte[]{0x12, 0x7f}));
    8884        Assert.assertEquals("fedc", Utils.toHexString(new byte[]{(byte) 0xfe, (byte) 0xdc}));
    89     }
    90 
    91     /**
    92      * Test of {@link Utils#openURLReaderAndDecompress} method with Gzip compression.
    93      * @throws IOException if any I/O error occurs
    94      */
    95     @Test
    96     public void testOpenUrlGzip() throws IOException {
    97         Main.initApplicationPreferences();
    98         final URL url = new URL("https://www.openstreetmap.org/trace/1613906/data");
    99         try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) {
    100             Assert.assertTrue(x.readLine().startsWith("<?xml version="));
    101         }
    102     }
    103 
    104     /**
    105      * Test of {@link Utils#openURLReaderAndDecompress} method with Bzip compression.
    106      * @throws IOException if any I/O error occurs
    107      */
    108     @Test
    109     public void testOpenUrlBzip() throws IOException {
    110         Main.initApplicationPreferences();
    111         final URL url = new URL("https://www.openstreetmap.org/trace/785544/data");
    112         try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) {
    113             Assert.assertTrue(x.readLine().startsWith("<?xml version="));
    114         }
    115     }
    116 
    117     /**
    118      * Test of {@link Utils#openURLReaderAndDecompress} method with Bzip compression.
    119      * @throws IOException if any I/O error occurs
    120      */
    121     @Test
    122     public void testTicket9660() throws IOException {
    123         Main.initApplicationPreferences();
    124         final URL url = new URL("http://www.openstreetmap.org/trace/1350010/data");
    125         try (BufferedReader x = HttpClient.create(url).connect()
    126                 .uncompress(true).uncompressAccordingToContentDisposition(true).getContentReader()) {
    127             Assert.assertTrue(x.readLine().startsWith("<?xml version="));
    128         }
    12985    }
    13086
Note: See TracChangeset for help on using the changeset viewer.