Skip to content

Commit 8aa7163

Browse files
committed
add test case for folder names with spaces
1 parent 7cbb254 commit 8aa7163

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.zapodot.junit.ldap.internal;
22

3+
import com.google.common.base.Charsets;
34
import com.google.common.io.Resources;
45
import com.sun.jndi.ldap.DefaultResponseControlFactory;
56
import com.sun.jndi.ldap.LdapCtxFactory;
@@ -8,7 +9,6 @@
89
import com.unboundid.ldap.sdk.LDAPConnection;
910
import com.unboundid.ldap.sdk.LDAPException;
1011
import com.unboundid.ldap.sdk.LDAPInterface;
11-
1212
import org.junit.runner.Description;
1313
import org.junit.runners.model.Statement;
1414
import org.slf4j.Logger;
@@ -22,7 +22,6 @@
2222
import javax.naming.directory.DirContext;
2323
import javax.naming.directory.InitialDirContext;
2424
import javax.naming.ldap.LdapContext;
25-
2625
import java.io.UnsupportedEncodingException;
2726
import java.net.URLDecoder;
2827
import java.util.Hashtable;
@@ -55,15 +54,18 @@ public static EmbeddedLdapRule createForConfiguration(final InMemoryDirectorySer
5554
}
5655
}
5756

58-
private static InMemoryDirectoryServer createServer(final InMemoryDirectoryServerConfig inMemoryDirectoryServerConfig, final List<String> ldifs) throws LDAPException {
57+
private static InMemoryDirectoryServer createServer(final InMemoryDirectoryServerConfig inMemoryDirectoryServerConfig,
58+
final List<String> ldifs) throws LDAPException {
5959
final InMemoryDirectoryServer ldapServer =
6060
new InMemoryDirectoryServer(inMemoryDirectoryServerConfig);
6161
if (ldifs != null && !ldifs.isEmpty()) {
6262
for (final String ldif : ldifs) {
6363
try {
64-
ldapServer.importFromLDIF(false, URLDecoder.decode(Resources.getResource(ldif).getPath(), "UTF-8"));
64+
ldapServer.importFromLDIF(false, URLDecoder.decode(Resources.getResource(ldif).getPath(),
65+
Charsets.UTF_8.name()));
6566
} catch (UnsupportedEncodingException e) {
66-
throw new IllegalStateException("Can not URL decode path:" + Resources.getResource(ldif).getPath(), e);
67+
throw new IllegalStateException("Can not URL decode path:" + Resources.getResource(ldif).getPath(),
68+
e);
6769
}
6870
}
6971
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.zapodot.junit.ldap;
2+
3+
import org.junit.Rule;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.assertNotNull;
7+
8+
public class EmbeddedLdapRuleWithSpacesTest {
9+
10+
@Rule
11+
public EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
12+
.newInstance()
13+
.usingDomainDsn("dc=zapodot,dc=org")
14+
.importingLdifs("folder with space/example.ldif")
15+
.build();
16+
17+
@Test
18+
public void testIsUp() throws Exception {
19+
assertNotNull(embeddedLdapRule.ldapConnection().getRootDSE());
20+
21+
}
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 1
2+
3+
dn: dc=zapodot,dc=org
4+
objectClass: domain
5+
objectClass: top
6+
dc: zapodot
7+
8+
dn: ou=groups,dc=zapodot,dc=org
9+
objectclass: top
10+
objectclass: organizationalUnit
11+
ou: groups
12+
13+
dn: ou=people,dc=zapodot,dc=org
14+
objectclass: top
15+
objectclass: organizationalUnit
16+
ou: people
17+
18+
dn: cn=Sondre Eikanger Kvalo,ou=people,dc=zapodot,dc=org
19+
objectclass: top
20+
objectclass: person
21+
objectclass: organizationalPerson
22+
objectclass: inetOrgPerson
23+
uid: zapodot
24+
userPassword: password
25+
cn: Sondre Eikanger Kvalo
26+
cn:: U29uZHJlIEVpa2FuZ2VyIEt2YWzDuA==
27+
sn: Person
28+
description: Developer

0 commit comments

Comments
 (0)