Changeset 10019 in josm for trunk/test


Ignore:
Timestamp:
2016-03-19T19:01:37+01:00 (9 years ago)
Author:
bastiK
Message:

fixed #12264 - repair unit test

adding certificates must happen before the first TLS connection is made
(don't know why, but so be it)

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r9801 r10019  
    55
    66import java.io.File;
     7import java.io.IOException;
    78import java.nio.file.Paths;
    89import java.text.MessageFormat;
     
    1213import org.openstreetmap.josm.gui.layer.Layer;
    1314import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     15import org.openstreetmap.josm.io.CertificateAmendment;
    1416import org.openstreetmap.josm.io.OsmApi;
    1517import org.openstreetmap.josm.tools.I18n;
     
    9395        I18n.set(Main.pref.get("language", "en"));
    9496
     97        try {
     98            CertificateAmendment.addMissingCertificates();
     99        } catch (IOException ex) {
     100            throw new RuntimeException(ex);
     101        }
     102
    95103        // init projection
    96104        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
  • trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTest.java

    r9996 r10019  
    2525    public static void setUp() throws IOException {
    2626        JOSMFixture.createUnitTestFixture().init();
    27         CertificateAmendment.addMissingCertificates();
    2827    }
    2928
     
    7069    }
    7170
    72     private void connect(String url, boolean shouldWork) throws IOException {
     71    /**
     72     * Test overpass API.
     73     * @throws IOException in case of I/O error
     74     */
     75    @Test
     76    public void testOverpass() throws IOException {
     77        connect("https://overpass-api.de", true);
     78    }
     79
     80    private static void connect(String url, boolean shouldWork) throws IOException {
    7381        URLConnection connection = new URL(url).openConnection();
    7482        try {
     
    7684        } catch (SSLHandshakeException e) {
    7785            if (shouldWork) {
     86                e.printStackTrace();
    7887                Assert.fail("Untrusted: " + url);
    7988            } else {
Note: See TracChangeset for help on using the changeset viewer.