Changeset 19708 in josm
- Timestamp:
- 2026-11-27T14:25:02+01:00 (less than one hour ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 4 edited
-
gui/ExceptionDialogUtilTest.java (modified) (3 diffs)
-
gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java (modified) (2 diffs)
-
io/OsmConnectionTest.java (modified) (2 diffs)
-
tools/ExceptionUtilTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/ExceptionDialogUtilTest.java
r19707 r19708 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.openstreetmap.josm.tools.I18n.tr; 7 8 8 9 import java.util.Collections; … … 41 42 @Test 42 43 void testMissingOAuthAccessTokenOffersThePreferences() { 43 assert Equals(1,explainMissingOAuthAccessToken("Open preferences"));44 assert Equals(0,explainMissingOAuthAccessToken("Close"));44 assertTrue(explainMissingOAuthAccessToken(tr("Open preferences")), "the preferences were not opened"); 45 assertFalse(explainMissingOAuthAccessToken(tr("Close")), "the preferences were opened"); 45 46 } 46 47 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) { 48 54 TestUtils.assumeWorkingJMockit(); 49 55 final MissingOAuthAccessTokenException e = MissingOAuthAccessTokenException.clientIdMissing("https://example.org/api"); … … 59 65 ExceptionDialogUtil.explainMissingOAuthAccessTokenException(e); 60 66 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(); 68 69 } 69 70 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanelTest.java
r19707 r19708 331 331 } 332 332 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)); 334 334 NetworkManager.setOffline(OnlineResource.ALL); 335 335 addAuthorization(OAuthVersion.OAuth20); … … 394 394 OpenBrowserMocker.getCalledURIs().clear(); 395 395 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)); 397 397 NetworkManager.setOffline(OnlineResource.ALL); 398 398 RemoteControl.stop(); -
trunk/test/unit/org/openstreetmap/josm/io/OsmConnectionTest.java
r19707 r19708 8 8 import static org.junit.jupiter.api.Assertions.assertThrows; 9 9 import static org.junit.jupiter.api.Assertions.assertTrue; 10 import static org.openstreetmap.josm.tools.I18n.tr; 10 11 11 12 import java.awt.GraphicsEnvironment; … … 141 142 } 142 143 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)); 144 145 rememberParameters(); 145 146 -
trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
r19707 r19708 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org. junit.jupiter.api.Assertions.assertTrue;5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 7 import java.io.IOException; … … 287 287 final String explanation = ExceptionUtil.explainMissingOAuthAccessTokenException( 288 288 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); 291 294 } 292 295
Note:
See TracChangeset
for help on using the changeset viewer.
