Changeset 19708 in josm


Ignore:
Timestamp:
2026-11-27T14:25:02+01:00 (less than one hour ago)
Author:
stoecker
Message:

see #24928 - adapt tests to be i18n sensitive

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

Legend:

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

    r19707 r19708  
    55import static org.junit.jupiter.api.Assertions.assertFalse;
    66import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.openstreetmap.josm.tools.I18n.tr;
    78
    89import java.util.Collections;
    … …  
    4142    @Test
    4243    void testMissingOAuthAccessTokenOffersThePreferences() {
    43         assertEquals(1, explainMissingOAuthAccessToken("Open preferences"));
    44         assertEquals(0, explainMissingOAuthAccessToken("Close"));
     44        assertTrue(explainMissingOAuthAccessToken(tr("Open preferences")), "the preferences were not opened");
     45        assertFalse(explainMissingOAuthAccessToken(tr("Close")), "the preferences were opened");
    4546    }
    4647
    47     private static int explainMissingOAuthAccessToken(String answer) {
     48    /**
     49     * Explains a missing OAuth client id, answering the dialog with the given button.
     50     * @param answer the text of the button
     51     * @return whether the preferences were opened
     52     */
     53    private static boolean explainMissingOAuthAccessToken(String answer) {
    4854        TestUtils.assumeWorkingJMockit();
    4955        final MissingOAuthAccessTokenException e = MissingOAuthAccessTokenException.clientIdMissing("https://example.org/api");
    … …  
    5965        ExceptionDialogUtil.explainMissingOAuthAccessTokenException(e);
    6066        assertEquals(1, mocker.getInvocationLog().size());
    61         assertEquals("Authentication failed", mocker.getInvocationLog().get(0)[2]);
    62         if (opened.get()) {
    63             assertTrue(answer.startsWith("Open"));
    64             return 1;
    65         }
    66         assertFalse(answer.startsWith("Open"));
    67         return 0;
     67        assertEquals(tr("Authentication failed"), mocker.getInvocationLog().get(0)[2]);
     68        return opened.get();
    6869    }
    6970}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java

    r19707 r19708  
    331331        }
    332332        final JOptionPaneSimpleMocker mocker = new JOptionPaneSimpleMocker(Collections.singletonMap(
    333                 "There is no Access Token to test.", JOptionPane.OK_OPTION));
     333                tr("There is no Access Token to test."), JOptionPane.OK_OPTION));
    334334        NetworkManager.setOffline(OnlineResource.ALL);
    335335        addAuthorization(OAuthVersion.OAuth20);
    … …  
    394394        OpenBrowserMocker.getCalledURIs().clear();
    395395        new JOptionPaneSimpleMocker(Collections.singletonMap(
    396                 "Authentication failed, please check browser for details.", JOptionPane.OK_OPTION));
     396                tr("Authentication failed, please check browser for details."), JOptionPane.OK_OPTION));
    397397        NetworkManager.setOffline(OnlineResource.ALL);
    398398        RemoteControl.stop();
  • trunk/test/unit/org/openstreetmap/josm/io/OsmConnectionTest.java

    r19707 r19708  
    88import static org.junit.jupiter.api.Assertions.assertThrows;
    99import static org.junit.jupiter.api.Assertions.assertTrue;
     10import static org.openstreetmap.josm.tools.I18n.tr;
    1011
    1112import java.awt.GraphicsEnvironment;
    … …  
    141142        }
    142143        final JOptionPaneSimpleMocker mocker = new JOptionPaneSimpleMocker(
    143                 Collections.singletonMap("Obtain OAuth 2.0 token for authentication?", JOptionPane.NO_OPTION));
     144                Collections.singletonMap(tr("Obtain OAuth 2.0 token for authentication?"), JOptionPane.NO_OPTION));
    144145        rememberParameters();
    145146
  • trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java

    r19707 r19708  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    5 import static org.junit.jupiter.api.Assertions.assertTrue;
     5import static org.openstreetmap.josm.tools.I18n.tr;
    66
    77import java.io.IOException;
    … …  
    287287        final String explanation = ExceptionUtil.explainMissingOAuthAccessTokenException(
    288288                MissingOAuthAccessTokenException.clientIdMissing("https://other.example.org/api"));
    289         assertTrue(explanation.contains("'https://other.example.org/api'"), explanation);
    290         assertTrue(explanation.contains("because it has no OAuth Client ID for it"), explanation);
     289        assertEquals(tr("<html>Failed to authenticate at the OSM server ''{0}''.<br>"
     290                + "JOSM cannot obtain an OAuth Access Token for this server, because it has no OAuth Client ID for it.<br>"
     291                + "Please register an OAuth 2.0 application on the server, and enter its Client ID in the OAuth<br>"
     292                + "settings of the Preferences Dialog; or enter an Access Token obtained outside JOSM there."
     293                + "</html>", "https://other.example.org/api"), explanation);
    291294    }
    292295
Note: See TracChangeset for help on using the changeset viewer.