Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

File:
1 edited

Legend:

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

    r16407 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.io.IOException;
     
    1111import java.util.TimeZone;
    1212
    13 import org.junit.Before;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     13import org.junit.jupiter.api.BeforeEach;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1616import org.openstreetmap.josm.io.ChangesetClosedException;
    1717import org.openstreetmap.josm.io.IllegalDataException;
     
    3131 * Unit tests of {@link ExceptionUtil} class.
    3232 */
    33 public class ExceptionUtilTest {
     33class ExceptionUtilTest {
    3434
    3535    /**
    3636     * Setup rule.
    3737     */
    38     @Rule
     38    @RegisterExtension
    3939    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4040    public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
     
    4949     * @throws Exception in case of error
    5050     */
    51     @Before
     51    @BeforeEach
    5252    public void setUp() throws Exception {
    5353        OsmApi api = OsmApi.getOsmApi();
     
    6363     */
    6464    @Test
    65     public void testExplainBadRequest() {
     65    void testExplainBadRequest() {
    6666        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>",
    6767                ExceptionUtil.explainBadRequest(new OsmApiException("")));
     
    9494     */
    9595    @Test
    96     public void testExplainBandwidthLimitExceeded() {
     96    void testExplainBandwidthLimitExceeded() {
    9797        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+
    9898                "The server replied<br>the following error code and the following error message:<br>"+
     
    105105     */
    106106    @Test
    107     public void testExplainChangesetClosedException() {
     107    void testExplainChangesetClosedException() {
    108108        assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.",
    109109                ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException("")));
     
    117117     */
    118118    @Test
    119     public void testExplainClientTimeout() {
     119    void testExplainClientTimeout() {
    120120        assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>",
    121121                ExceptionUtil.explainClientTimeout(new OsmApiException("")));
     
    126126     */
    127127    @Test
    128     public void testExplainConflict() {
     128    void testExplainConflict() {
    129129        int code = HttpURLConnection.HTTP_CONFLICT;
    130130        assertEquals("<html>The server reported that it has detected a conflict.</html>",
     
    146146     */
    147147    @Test
    148     public void testExplainException() {
     148    void testExplainException() {
    149149        assertEquals("ResponseCode=0",
    150150                ExceptionUtil.explainException(new OsmApiException("")));
     
    161161     */
    162162    @Test
    163     public void testExplainFailedAuthorisation() {
     163    void testExplainFailedAuthorisation() {
    164164        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
    165165                "'The server replied an error with code 0.'</html>",
     
    183183     */
    184184    @Test
    185     public void testExplainFailedOAuthAuthorisation() {
     185    void testExplainFailedOAuthAuthorisation() {
    186186        assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+
    187187                "The token is not authorised to access the protected resource<br>'unknown'.<br>"+
     
    198198     */
    199199    @Test
    200     public void testExplainFailedBasicAuthentication() {
     200    void testExplainFailedBasicAuthentication() {
    201201        assertEquals("<html>Authentication at the OSM server with the username '"+user+"' failed.<br>"+
    202202                "Please check the username and the password in the JOSM preferences.</html>",
     
    208208     */
    209209    @Test
    210     public void testExplainFailedOAuthAuthentication() {
     210    void testExplainFailedOAuthAuthentication() {
    211211        assertEquals("<html>Authentication at the OSM server with the OAuth token 'null' failed.<br>"+
    212212                "Please launch the preferences dialog and retrieve another OAuth token.</html>",
     
    218218     */
    219219    @Test
    220     public void testExplainGenericOsmApiException() {
     220    void testExplainGenericOsmApiException() {
    221221        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
    222222                "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+
     
    239239     */
    240240    @Test
    241     public void testExplainGoneForUnknownPrimitive() {
     241    void testExplainGoneForUnknownPrimitive() {
    242242        assertEquals("<html>The server reports that an object is deleted.<br>"+
    243243                "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+
     
    251251     */
    252252    @Test
    253     public void testExplainInternalServerError() {
     253    void testExplainInternalServerError() {
    254254        assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
    255255                "This is most likely a temporary problem. Please try again later.</html>",
     
    261261     */
    262262    @Test
    263     public void testExplainMissingOAuthAccessTokenException() {
     263    void testExplainMissingOAuthAccessTokenException() {
    264264        assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+
    265265                "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+
     
    272272     */
    273273    @Test
    274     public void testExplainNestedIllegalDataException() {
     274    void testExplainNestedIllegalDataException() {
    275275        assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+
    276276                "Details (untranslated): null</html>",
     
    286286     */
    287287    @Test
    288     public void testExplainNestedIOException() {
     288    void testExplainNestedIOException() {
    289289        assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
    290290                "due to a problem with transferring data.<br>Details (untranslated): null</html>",
     
    300300     */
    301301    @Test
    302     public void testExplainNestedSocketException() {
     302    void testExplainNestedSocketException() {
    303303        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
    304304                "Please check your internet connection.</html>",
     
    310310     */
    311311    @Test
    312     public void testExplainNestedUnknownHostException() {
     312    void testExplainNestedUnknownHostException() {
    313313        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
    314314                "Host name '"+host+"' could not be resolved. <br>"+
     
    321321     */
    322322    @Test
    323     public void testExplainNotFound() {
     323    void testExplainNotFound() {
    324324        assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+
    325325                "you tried to read, update, or delete. Either the respective object<br>"+
     
    333333     */
    334334    @Test
    335     public void testExplainOfflineAccessException() {
     335    void testExplainOfflineAccessException() {
    336336        assertEquals("<html>Failed to download data.<br><br>Details: null</html>",
    337337                ExceptionUtil.explainOfflineAccessException(new OsmApiException("")));
     
    344344     */
    345345    @Test
    346     public void testExplainOsmApiInitializationException() {
     346    void testExplainOsmApiInitializationException() {
    347347        assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
    348348                "Check the server URL in your preferences and your internet connection.</html>",
     
    354354     */
    355355    @Test
    356     public void testExplainOsmTransferException() {
     356    void testExplainOsmTransferException() {
    357357        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+
    358358                "for security reasons. This is most likely because you are running<br>"+
     
    410410     */
    411411    @Test
    412     public void testExplainPreconditionFailed() {
     412    void testExplainPreconditionFailed() {
    413413        int code = HttpURLConnection.HTTP_PRECON_FAILED;
    414414        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.