Changeset 11943 in josm for trunk/test


Ignore:
Timestamp:
2017-04-17T14:07:04+02:00 (2 years ago)
Author:
Don-vip
Message:

fix #14649 - load Dutch Government (G2 & G3) certificates from Windows keystore if not found in Java keystore

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r10899 r11943  
    2222import org.openstreetmap.josm.io.OsmApi;
    2323import org.openstreetmap.josm.tools.I18n;
     24import org.openstreetmap.josm.tools.JosmRuntimeException;
    2425import org.openstreetmap.josm.tools.Logging;
    2526
     
    111112            CertificateAmendment.addMissingCertificates();
    112113        } catch (IOException | GeneralSecurityException ex) {
    113             throw new RuntimeException(ex);
     114            throw new JosmRuntimeException(ex);
    114115        }
    115116
  • trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTest.java

    r11923 r11943  
    2626    @Rule
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules();
     28    public JOSMTestRules test = new JOSMTestRules().platform().https();
    2929
    3030    /**
     
    8282    }
    8383
     84    /**
     85     * Test Dutch government.
     86     * @throws IOException in case of I/O error
     87     */
     88    @Test
     89    public void testDutchGovernment() throws IOException {
     90        connect("https://geodata.nationaalgeoregister.nl", true);
     91    }
     92
    8493    private static void connect(String url, boolean shouldWork) throws IOException {
    8594        URLConnection connection = new URL(url).openConnection();
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r11777 r11943  
    44import java.io.File;
    55import java.io.IOException;
     6import java.security.GeneralSecurityException;
    67import java.text.MessageFormat;
    78import java.util.TimeZone;
     
    1718import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    1819import org.openstreetmap.josm.gui.util.GuiHelper;
     20import org.openstreetmap.josm.io.CertificateAmendment;
    1921import org.openstreetmap.josm.io.OsmApi;
    2022import org.openstreetmap.josm.io.OsmApiInitializationException;
    2123import org.openstreetmap.josm.io.OsmTransferCanceledException;
    2224import org.openstreetmap.josm.tools.I18n;
     25import org.openstreetmap.josm.tools.JosmRuntimeException;
    2326import org.openstreetmap.josm.tools.Logging;
    2427import org.openstreetmap.josm.tools.MemoryManagerTest;
     
    4649    private boolean allowMemoryManagerLeaks;
    4750    private boolean useMapStyles;
     51    private boolean useHttps;
    4852
    4953    /**
     
    137141    public JOSMTestRules projection() {
    138142        useProjection = true;
     143        return this;
     144    }
     145
     146    /**
     147     * Set up HTTPS certificates
     148     * @return this instance, for easy chaining
     149     */
     150    public JOSMTestRules https() {
     151        useHttps = true;
    139152        return this;
    140153    }
     
    222235        }
    223236
     237        // Set Platform
     238        if (platform) {
     239            Main.determinePlatformHook();
     240        }
     241
     242        if (useHttps) {
     243            try {
     244                CertificateAmendment.addMissingCertificates();
     245            } catch (IOException | GeneralSecurityException ex) {
     246                throw new JosmRuntimeException(ex);
     247            }
     248        }
     249
    224250        if (useProjection) {
    225251            Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     
    241267                throw new InitializationError(e);
    242268            }
    243         }
    244 
    245         // Set Platform
    246         if (platform) {
    247             Main.determinePlatformHook();
    248269        }
    249270
Note: See TracChangeset for help on using the changeset viewer.