Skip to content

Commit ed9b2c1

Browse files
committed
Support file paths with spaces
1 parent ef398e6 commit ed9b2c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/org/zapodot/junit/ldap/internal/EmbeddedLdapRuleImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.unboundid.ldap.sdk.LDAPConnection;
99
import com.unboundid.ldap.sdk.LDAPException;
1010
import com.unboundid.ldap.sdk.LDAPInterface;
11+
1112
import org.junit.runner.Description;
1213
import org.junit.runners.model.Statement;
1314
import org.slf4j.Logger;
@@ -21,6 +22,9 @@
2122
import javax.naming.directory.DirContext;
2223
import javax.naming.directory.InitialDirContext;
2324
import javax.naming.ldap.LdapContext;
25+
26+
import java.io.UnsupportedEncodingException;
27+
import java.net.URLDecoder;
2428
import java.util.Hashtable;
2529
import java.util.List;
2630

@@ -56,7 +60,11 @@ private static InMemoryDirectoryServer createServer(final InMemoryDirectoryServe
5660
new InMemoryDirectoryServer(inMemoryDirectoryServerConfig);
5761
if (ldifs != null && !ldifs.isEmpty()) {
5862
for (final String ldif : ldifs) {
59-
ldapServer.importFromLDIF(false, Resources.getResource(ldif).getPath());
63+
try {
64+
ldapServer.importFromLDIF(false, URLDecoder.decode(Resources.getResource(ldif).getPath(), "UTF-8"));
65+
} catch (UnsupportedEncodingException e) {
66+
throw new IllegalStateException("Can not URL decode path:" + Resources.getResource(ldif).getPath(), e);
67+
}
6068
}
6169
}
6270
return ldapServer;

0 commit comments

Comments
 (0)