Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
- Timestamp:
- 2020-10-28T20:41:00+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
r16407 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.io.IOException; … … 11 11 import java.util.TimeZone; 12 12 13 import org.junit. Before;14 import org.junit. Rule;15 import org.junit. Test;13 import org.junit.jupiter.api.BeforeEach; 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 16 16 import org.openstreetmap.josm.io.ChangesetClosedException; 17 17 import org.openstreetmap.josm.io.IllegalDataException; … … 31 31 * Unit tests of {@link ExceptionUtil} class. 32 32 */ 33 publicclass ExceptionUtilTest {33 class ExceptionUtilTest { 34 34 35 35 /** 36 36 * Setup rule. 37 37 */ 38 @R ule38 @RegisterExtension 39 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 40 40 public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI(); … … 49 49 * @throws Exception in case of error 50 50 */ 51 @Before 51 @BeforeEach 52 52 public void setUp() throws Exception { 53 53 OsmApi api = OsmApi.getOsmApi(); … … 63 63 */ 64 64 @Test 65 publicvoid testExplainBadRequest() {65 void testExplainBadRequest() { 66 66 assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>", 67 67 ExceptionUtil.explainBadRequest(new OsmApiException(""))); … … 94 94 */ 95 95 @Test 96 publicvoid testExplainBandwidthLimitExceeded() {96 void testExplainBandwidthLimitExceeded() { 97 97 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+ 98 98 "The server replied<br>the following error code and the following error message:<br>"+ … … 105 105 */ 106 106 @Test 107 publicvoid testExplainChangesetClosedException() {107 void testExplainChangesetClosedException() { 108 108 assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.", 109 109 ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException(""))); … … 117 117 */ 118 118 @Test 119 publicvoid testExplainClientTimeout() {119 void testExplainClientTimeout() { 120 120 assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>", 121 121 ExceptionUtil.explainClientTimeout(new OsmApiException(""))); … … 126 126 */ 127 127 @Test 128 publicvoid testExplainConflict() {128 void testExplainConflict() { 129 129 int code = HttpURLConnection.HTTP_CONFLICT; 130 130 assertEquals("<html>The server reported that it has detected a conflict.</html>", … … 146 146 */ 147 147 @Test 148 publicvoid testExplainException() {148 void testExplainException() { 149 149 assertEquals("ResponseCode=0", 150 150 ExceptionUtil.explainException(new OsmApiException(""))); … … 161 161 */ 162 162 @Test 163 publicvoid testExplainFailedAuthorisation() {163 void testExplainFailedAuthorisation() { 164 164 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+ 165 165 "'The server replied an error with code 0.'</html>", … … 183 183 */ 184 184 @Test 185 publicvoid testExplainFailedOAuthAuthorisation() {185 void testExplainFailedOAuthAuthorisation() { 186 186 assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+ 187 187 "The token is not authorised to access the protected resource<br>'unknown'.<br>"+ … … 198 198 */ 199 199 @Test 200 publicvoid testExplainFailedBasicAuthentication() {200 void testExplainFailedBasicAuthentication() { 201 201 assertEquals("<html>Authentication at the OSM server with the username '"+user+"' failed.<br>"+ 202 202 "Please check the username and the password in the JOSM preferences.</html>", … … 208 208 */ 209 209 @Test 210 publicvoid testExplainFailedOAuthAuthentication() {210 void testExplainFailedOAuthAuthentication() { 211 211 assertEquals("<html>Authentication at the OSM server with the OAuth token 'null' failed.<br>"+ 212 212 "Please launch the preferences dialog and retrieve another OAuth token.</html>", … … 218 218 */ 219 219 @Test 220 publicvoid testExplainGenericOsmApiException() {220 void testExplainGenericOsmApiException() { 221 221 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+ 222 222 "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+ … … 239 239 */ 240 240 @Test 241 publicvoid testExplainGoneForUnknownPrimitive() {241 void testExplainGoneForUnknownPrimitive() { 242 242 assertEquals("<html>The server reports that an object is deleted.<br>"+ 243 243 "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+ … … 251 251 */ 252 252 @Test 253 publicvoid testExplainInternalServerError() {253 void testExplainInternalServerError() { 254 254 assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+ 255 255 "This is most likely a temporary problem. Please try again later.</html>", … … 261 261 */ 262 262 @Test 263 publicvoid testExplainMissingOAuthAccessTokenException() {263 void testExplainMissingOAuthAccessTokenException() { 264 264 assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+ 265 265 "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+ … … 272 272 */ 273 273 @Test 274 publicvoid testExplainNestedIllegalDataException() {274 void testExplainNestedIllegalDataException() { 275 275 assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+ 276 276 "Details (untranslated): null</html>", … … 286 286 */ 287 287 @Test 288 publicvoid testExplainNestedIOException() {288 void testExplainNestedIOException() { 289 289 assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+ 290 290 "due to a problem with transferring data.<br>Details (untranslated): null</html>", … … 300 300 */ 301 301 @Test 302 publicvoid testExplainNestedSocketException() {302 void testExplainNestedSocketException() { 303 303 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+ 304 304 "Please check your internet connection.</html>", … … 310 310 */ 311 311 @Test 312 publicvoid testExplainNestedUnknownHostException() {312 void testExplainNestedUnknownHostException() { 313 313 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+ 314 314 "Host name '"+host+"' could not be resolved. <br>"+ … … 321 321 */ 322 322 @Test 323 publicvoid testExplainNotFound() {323 void testExplainNotFound() { 324 324 assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+ 325 325 "you tried to read, update, or delete. Either the respective object<br>"+ … … 333 333 */ 334 334 @Test 335 publicvoid testExplainOfflineAccessException() {335 void testExplainOfflineAccessException() { 336 336 assertEquals("<html>Failed to download data.<br><br>Details: null</html>", 337 337 ExceptionUtil.explainOfflineAccessException(new OsmApiException(""))); … … 344 344 */ 345 345 @Test 346 publicvoid testExplainOsmApiInitializationException() {346 void testExplainOsmApiInitializationException() { 347 347 assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+ 348 348 "Check the server URL in your preferences and your internet connection.</html>", … … 354 354 */ 355 355 @Test 356 publicvoid testExplainOsmTransferException() {356 void testExplainOsmTransferException() { 357 357 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+ 358 358 "for security reasons. This is most likely because you are running<br>"+ … … 410 410 */ 411 411 @Test 412 publicvoid testExplainPreconditionFailed() {412 void testExplainPreconditionFailed() { 413 413 int code = HttpURLConnection.HTTP_PRECON_FAILED; 414 414 assertEquals("<html>Uploading to the server <strong>failed</strong> because your current<br>dataset violates a precondition.<br>"+
Note:
See TracChangeset
for help on using the changeset viewer.