Make it possible to specify ldif file for LDAPEmbeddedServer

This commit is contained in:
Stian Thorgersen committed 2015-06-17 13:53:11 +02:00
1 parent de6341bd87
commit dca347398d
1 file changed
+7 -1
@@ -2,6 +2,7 @@ package org.keycloak.testsuite.ldap;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -148,7 +149,12 @@ public class LDAPEmbeddedServer {
}
// For now, assume that LDIF file is on classpath
InputStream is = getClass().getClassLoader().getResourceAsStream(ldifFile);
InputStream is;
if (ldifFile.startsWith("file:")) {
is = new URL(ldifFile).openStream();
} else {
is = getClass().getClassLoader().getResourceAsStream(ldifFile);
}
if (is == null) {
throw new IllegalStateException("LDIF file not found on classpath. Location was: " + ldifFile);
}