Changeset 7081 in josm for trunk/test/unit/org/openstreetmap/josm/io/remotecontrol
- Timestamp:
- 2014-05-09T04:49:54+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r7040 r7081 26 26 import org.junit.Before; 27 27 import org.junit.Test; 28 import org.openstreetmap.josm.JOSMFixture; 28 29 import org.openstreetmap.josm.Main; 29 30 import org.openstreetmap.josm.tools.Utils; … … 36 37 private String httpBase; 37 38 private String httpsBase; 38 39 39 40 /** 40 41 * Starts Remote control before testing requests. … … 42 43 @Before 43 44 public void setUp() { 44 Main.initApplicationPreferences();45 JOSMFixture.createUnitTestFixture().init(); 45 46 RemoteControl.start(); 46 47 disableCertificateValidation(); … … 48 49 httpsBase = "https://127.0.0.1:"+Main.pref.getInteger("remote.control.https.port", 8112); 49 50 } 50 51 51 52 /** 52 * Disable all HTTPS validation mechanisms as described 53 * Disable all HTTPS validation mechanisms as described 53 54 * <a href="http://stackoverflow.com/a/2893932/2257172">here</a> and 54 55 * <a href="http://stackoverflow.com/a/19542614/2257172">here</a> … … 56 57 public void disableCertificateValidation() { 57 58 // Create a trust manager that does not validate certificate chains 58 TrustManager[] trustAllCerts = new TrustManager[] { 59 TrustManager[] trustAllCerts = new TrustManager[] { 59 60 new X509TrustManager() { 60 61 public X509Certificate[] getAcceptedIssuers() { … … 76 77 fail(e.getMessage()); 77 78 } 78 79 79 80 // Create all-trusting host name verifier 80 81 HostnameVerifier allHostsValid = new HostnameVerifier() { … … 100 101 * Tests that sending an HTTP request without command results in HTTP 400, with all available commands in error message. 101 102 * @throws IOException if an I/O error occurs 102 * @throws MalformedURLException if HTTP URL is invalid 103 * @throws MalformedURLException if HTTP URL is invalid 103 104 */ 104 105 @Test … … 110 111 * Tests that sending an HTTPS request without command results in HTTP 400, with all available commands in error message. 111 112 * @throws IOException if an I/O error occurs 112 * @throws MalformedURLException if HTTPS URL is invalid 113 * @throws MalformedURLException if HTTPS URL is invalid 113 114 */ 114 115 @Test … … 122 123 assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST); 123 124 try (InputStream is = connection.getErrorStream()) { 124 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 125 // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes 125 126 StringBuilder responseBody = new StringBuilder(); 126 127 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, Utils.UTF_8))) {
Note:
See TracChangeset
for help on using the changeset viewer.