|
1 | 1 | package org.zapodot.junit.ldap.internal; |
2 | 2 |
|
| 3 | +import com.google.common.base.Charsets; |
3 | 4 | import com.google.common.io.Resources; |
4 | 5 | import com.sun.jndi.ldap.DefaultResponseControlFactory; |
5 | 6 | import com.sun.jndi.ldap.LdapCtxFactory; |
|
8 | 9 | import com.unboundid.ldap.sdk.LDAPConnection; |
9 | 10 | import com.unboundid.ldap.sdk.LDAPException; |
10 | 11 | import com.unboundid.ldap.sdk.LDAPInterface; |
11 | | - |
12 | 12 | import org.junit.runner.Description; |
13 | 13 | import org.junit.runners.model.Statement; |
14 | 14 | import org.slf4j.Logger; |
|
22 | 22 | import javax.naming.directory.DirContext; |
23 | 23 | import javax.naming.directory.InitialDirContext; |
24 | 24 | import javax.naming.ldap.LdapContext; |
25 | | - |
26 | 25 | import java.io.UnsupportedEncodingException; |
27 | 26 | import java.net.URLDecoder; |
28 | 27 | import java.util.Hashtable; |
@@ -55,15 +54,18 @@ public static EmbeddedLdapRule createForConfiguration(final InMemoryDirectorySer |
55 | 54 | } |
56 | 55 | } |
57 | 56 |
|
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 { |
59 | 59 | final InMemoryDirectoryServer ldapServer = |
60 | 60 | new InMemoryDirectoryServer(inMemoryDirectoryServerConfig); |
61 | 61 | if (ldifs != null && !ldifs.isEmpty()) { |
62 | 62 | for (final String ldif : ldifs) { |
63 | 63 | 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())); |
65 | 66 | } 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); |
67 | 69 | } |
68 | 70 | } |
69 | 71 | } |
|
0 commit comments