Changeset 15084 in josm for trunk/test
- Timestamp:
- 2019-05-18T16:29:09+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
r13812 r15084 11 11 import java.util.TimeZone; 12 12 13 import org.junit.BeforeClass; 13 import org.junit.Before; 14 import org.junit.Rule; 14 15 import org.junit.Test; 15 import org.openstreetmap.josm.JOSMFixture;16 16 import org.openstreetmap.josm.io.ChangesetClosedException; 17 17 import org.openstreetmap.josm.io.IllegalDataException; … … 22 22 import org.openstreetmap.josm.io.OsmApiInitializationException; 23 23 import org.openstreetmap.josm.io.auth.CredentialsManager; 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 24 25 import org.openstreetmap.josm.tools.date.DateUtils; 25 26 import org.openstreetmap.josm.tools.date.DateUtilsTest; 27 28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 26 29 27 30 /** … … 30 33 public class ExceptionUtilTest { 31 34 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 32 42 private static String baseUrl; 33 43 private static String serverUrl; … … 39 49 * @throws Exception in case of error 40 50 */ 41 @BeforeClass 42 public static void setUp() throws Exception { 43 JOSMFixture.createUnitTestFixture().init(); 51 @Before 52 public void setUp() throws Exception { 44 53 OsmApi api = OsmApi.getOsmApi(); 45 api.initialize(null);46 54 baseUrl = api.getBaseUrl(); 47 55 serverUrl = api.getServerUrl(); … … 154 162 @Test 155 163 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>", 157 166 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>", 159 168 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>", 161 170 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>", 163 172 ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, null, "body"))); 164 173 } … … 247 256 @Test 248 257 public void testExplainMissingOAuthAccessTokenException() { 249 assertEquals("<html>Failed to authenticate at the OSM server 'http s://api06.dev.openstreetmap.org/api'.<br>"+258 assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+ 250 259 "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+ 251 260 "Please open the Preferences Dialog and generate or enter an Access Token.</html>",
Note:
See TracChangeset
for help on using the changeset viewer.