Changeset 15058 in josm


Ignore:
Timestamp:
2019-05-06T23:42:21+02:00 (6 years ago)
Author:
Don-vip
Message:

make CertificateAmendmentTestIT use https://josm.openstreetmap.de/wiki/IntegrationTestIgnores to avoid random failures of Taiwanese government server

File:
1 edited

Legend:

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

    r14498 r15058  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
     3
     4import static org.junit.Assume.assumeFalse;
    35
    46import java.io.IOException;
    57import java.net.URL;
    68import java.net.URLConnection;
     9import java.util.ArrayList;
     10import java.util.List;
    711
    812import javax.net.ssl.SSLHandshakeException;
    913
    1014import org.junit.Assert;
    11 import org.junit.Rule;
     15import org.junit.BeforeClass;
     16import org.junit.ClassRule;
    1217import org.junit.Test;
     18import org.openstreetmap.josm.TestUtils;
    1319import org.openstreetmap.josm.testutils.JOSMTestRules;
    1420
     
    2329     * Setup rule
    2430     */
    25     @Rule
     31    @ClassRule
    2632    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    27     public JOSMTestRules test = new JOSMTestRules().https().timeout(20000);
     33    public static JOSMTestRules test = new JOSMTestRules().https().preferences().timeout(20000);
     34
     35    private static final List<String> errorsToIgnore = new ArrayList<>();
     36
     37    /**
     38     * Setup test
     39     * @throws IOException in case of I/O error
     40     */
     41    @BeforeClass
     42    public static void beforeClass() throws IOException {
     43        errorsToIgnore.addAll(TestUtils.getIgnoredErrorMessages(CertificateAmendmentTestIT.class));
     44    }
    2845
    2946    /**
     
    95112            connection.connect();
    96113        } catch (SSLHandshakeException e) {
     114            String error = "Untrusted: " + url;
     115            assumeFalse(errorsToIgnore.contains(error));
    97116            if (shouldWork) {
    98                 throw new IOException("Untrusted: " + url, e);
     117                throw new IOException(error, e);
    99118            } else {
    100119                return;
    101120            }
    102121        }
     122        String error = "Expected error: " + url;
     123        assumeFalse(errorsToIgnore.contains(error));
    103124        if (!shouldWork) {
    104             Assert.fail("Expected error: " + url);
     125            Assert.fail(error);
    105126        }
    106127    }
Note: See TracChangeset for help on using the changeset viewer.