mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
19.06.2013 64cb165810e68656b711e4136e4a3ef4e80f8845
* Fixed failing test : ConnectionFactoryProviderTest unable to read truststore file when execution path contains whitespace (which is the case when running on Jenkins)
* Avoid reading twice the value of trustStorePathArg and keyStorePathArg in getConnectionFactory method
2 files modified
11 ■■■■■ changed files
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProviderTest.java 5 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java
@@ -378,7 +378,7 @@
            if (trustStorePathArg.isPresent()) {
                // Check that the path exists and is readable
                final String value = trustStorePathArg.getValue();
                if (!canRead(trustStorePathArg.getValue())) {
                if (!canReadPath(value)) {
                    final LocalizableMessage message = ERR_CANNOT_READ_TRUSTSTORE.get(value);
                    throw new ArgumentException(message);
                }
@@ -387,7 +387,7 @@
            if (keyStorePathArg.isPresent()) {
                // Check that the path exists and is readable
                final String value = keyStorePathArg.getValue();
                if (!canRead(keyStorePathArg.getValue())) {
                if (!canReadPath(value)) {
                    final LocalizableMessage message = ERR_CANNOT_READ_KEYSTORE.get(value);
                    throw new ArgumentException(message);
                }
@@ -464,7 +464,7 @@
     * @return <CODE>true</CODE> if we can read on the provided path and
     *         <CODE>false</CODE> otherwise.
     */
    private boolean canRead(final String path) {
    private boolean canReadPath(final String path) {
        boolean canRead;
        final File file = new File(path);
        canRead = file.exists() && file.canRead();
opendj3/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProviderTest.java
@@ -27,6 +27,8 @@
import static org.fest.assertions.Assertions.*;
import java.io.File;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.mockito.Mock;
@@ -54,7 +56,8 @@
    /** Issue OPENDJ-734 */
    public void getConnectionFactoryShouldAllowNullTrustStorePassword() throws Exception {
        // provide a trustStorePath but no password
        String trustStorePath = getClass().getClassLoader().getResource("dummy-truststore").getFile();
        String trustStorePath = new File(getClass().getClassLoader().getResource("dummy-truststore").toURI())
                .getCanonicalPath();
        argParser.parseArguments(new String[] { "--useStartTLS", "--trustStorePath", trustStorePath });
        ConnectionFactory factory = connectionFactoryProvider.getConnectionFactory();