Changeset 15084 in josm for trunk/test


Ignore:
Timestamp:
2019-05-18T16:29:09+02:00 (5 years ago)
Author:
Don-vip
Message:

see #17722 - proper notification of user block

File:
1 edited

Legend:

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

    r13812 r15084  
    1111import java.util.TimeZone;
    1212
    13 import org.junit.BeforeClass;
     13import org.junit.Before;
     14import org.junit.Rule;
    1415import org.junit.Test;
    15 import org.openstreetmap.josm.JOSMFixture;
    1616import org.openstreetmap.josm.io.ChangesetClosedException;
    1717import org.openstreetmap.josm.io.IllegalDataException;
     
    2222import org.openstreetmap.josm.io.OsmApiInitializationException;
    2323import org.openstreetmap.josm.io.auth.CredentialsManager;
     24import org.openstreetmap.josm.testutils.JOSMTestRules;
    2425import org.openstreetmap.josm.tools.date.DateUtils;
    2526import org.openstreetmap.josm.tools.date.DateUtilsTest;
     27
     28import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2629
    2730/**
     
    3033public class ExceptionUtilTest {
    3134
     35    /**
     36     * Setup rule.
     37     */
     38    @Rule
     39    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     40    public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
     41
    3242    private static String baseUrl;
    3343    private static String serverUrl;
     
    3949     * @throws Exception in case of error
    4050     */
    41     @BeforeClass
    42     public static void setUp() throws Exception {
    43         JOSMFixture.createUnitTestFixture().init();
     51    @Before
     52    public void setUp() throws Exception {
    4453        OsmApi api = OsmApi.getOsmApi();
    45         api.initialize(null);
    4654        baseUrl = api.getBaseUrl();
    4755        serverUrl = api.getServerUrl();
     
    154162    @Test
    155163    public void testExplainFailedAuthorisation() {
    156         assertEquals("<html>Authorisation at the OSM server failed.<br></html>",
     164        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
     165                "'The server replied an error with code 0.'</html>",
    157166                ExceptionUtil.explainFailedAuthorisation(new OsmApiException("")));
    158         assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'header'</html>",
     167        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'header (Code=403)'</html>",
    159168                ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "header", null)));
    160         assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'header (body)'</html>",
     169        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'header. body (Code=403)'</html>",
    161170                ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "header", "body")));
    162         assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'body'</html>",
     171        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>'body (Code=403)'</html>",
    163172                ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, null, "body")));
    164173    }
     
    247256    @Test
    248257    public void testExplainMissingOAuthAccessTokenException() {
    249         assertEquals("<html>Failed to authenticate at the OSM server 'https://api06.dev.openstreetmap.org/api'.<br>"+
     258        assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+
    250259                "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+
    251260                "Please open the Preferences Dialog and generate or enter an Access Token.</html>",
Note: See TracChangeset for help on using the changeset viewer.