Ignore:
Timestamp:
2014-05-09T04:49:54+02:00 (11 years ago)
Author:
Don-vip
Message:

fixes for unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java

    r7040 r7081  
    2626import org.junit.Before;
    2727import org.junit.Test;
     28import org.openstreetmap.josm.JOSMFixture;
    2829import org.openstreetmap.josm.Main;
    2930import org.openstreetmap.josm.tools.Utils;
     
    3637    private String httpBase;
    3738    private String httpsBase;
    38    
     39
    3940    /**
    4041     * Starts Remote control before testing requests.
     
    4243    @Before
    4344    public void setUp() {
    44         Main.initApplicationPreferences();
     45        JOSMFixture.createUnitTestFixture().init();
    4546        RemoteControl.start();
    4647        disableCertificateValidation();
     
    4849        httpsBase = "https://127.0.0.1:"+Main.pref.getInteger("remote.control.https.port", 8112);
    4950    }
    50    
     51
    5152    /**
    52      * Disable all HTTPS validation mechanisms as described 
     53     * Disable all HTTPS validation mechanisms as described
    5354     * <a href="http://stackoverflow.com/a/2893932/2257172">here</a> and
    5455     * <a href="http://stackoverflow.com/a/19542614/2257172">here</a>
     
    5657    public void disableCertificateValidation() {
    5758        // Create a trust manager that does not validate certificate chains
    58         TrustManager[] trustAllCerts = new TrustManager[] { 
     59        TrustManager[] trustAllCerts = new TrustManager[] {
    5960            new X509TrustManager() {
    6061                public X509Certificate[] getAcceptedIssuers() {
     
    7677            fail(e.getMessage());
    7778        }
    78        
     79
    7980        // Create all-trusting host name verifier
    8081        HostnameVerifier allHostsValid = new HostnameVerifier() {
     
    100101     * Tests that sending an HTTP request without command results in HTTP 400, with all available commands in error message.
    101102     * @throws IOException if an I/O error occurs
    102      * @throws MalformedURLException if HTTP URL is invalid 
     103     * @throws MalformedURLException if HTTP URL is invalid
    103104     */
    104105    @Test
     
    110111     * Tests that sending an HTTPS request without command results in HTTP 400, with all available commands in error message.
    111112     * @throws IOException if an I/O error occurs
    112      * @throws MalformedURLException if HTTPS URL is invalid 
     113     * @throws MalformedURLException if HTTPS URL is invalid
    113114     */
    114115    @Test
     
    122123        assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST);
    123124        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
    125126            StringBuilder responseBody = new StringBuilder();
    126127            try (BufferedReader in = new BufferedReader(new InputStreamReader(is, Utils.UTF_8))) {
Note: See TracChangeset for help on using the changeset viewer.