mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-03 11:59:08 +00:00
Move the apacheDS working directory to java.io.tmpdir
This commit is contained in:
parent
1f66750e24
commit
069f78c00b
@ -35,8 +35,13 @@ import javax.naming.directory.DirContext;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* An embedded LDAP test server, complete with test data for running the
|
||||||
|
* unit tests against.
|
||||||
|
*
|
||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
@ -48,6 +53,11 @@ public class LdapTestServer {
|
|||||||
|
|
||||||
private StartupConfiguration cfg;
|
private StartupConfiguration cfg;
|
||||||
|
|
||||||
|
// Move the working dir to the temp directory
|
||||||
|
private File workingDir = new File( System.getProperty("java.io.tmpdir")
|
||||||
|
+ File.separator + "apacheds-work" );
|
||||||
|
|
||||||
|
|
||||||
//~ Constructors ================================================================
|
//~ Constructors ================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,12 +76,17 @@ public class LdapTestServer {
|
|||||||
|
|
||||||
|
|
||||||
private void startLdapServer(boolean embedded) {
|
private void startLdapServer(boolean embedded) {
|
||||||
|
|
||||||
if(embedded) {
|
if(embedded) {
|
||||||
cfg = new MutableStartupConfiguration();
|
cfg = new MutableStartupConfiguration();
|
||||||
|
((MutableStartupConfiguration)cfg).setWorkingDirectory(workingDir);
|
||||||
} else {
|
} else {
|
||||||
cfg = new MutableServerStartupConfiguration();
|
cfg = new MutableServerStartupConfiguration();
|
||||||
|
((MutableServerStartupConfiguration)cfg).setWorkingDirectory(workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Working directory is " + workingDir.getAbsolutePath());
|
||||||
|
|
||||||
initConfiguration();
|
initConfiguration();
|
||||||
|
|
||||||
Properties env = new Properties();
|
Properties env = new Properties();
|
||||||
@ -82,7 +97,6 @@ public class LdapTestServer {
|
|||||||
env.putAll( cfg.toJndiEnvironment() );
|
env.putAll( cfg.toJndiEnvironment() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: Remove all children on startup
|
|
||||||
serverContext = new InitialDirContext( env );
|
serverContext = new InitialDirContext( env );
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
System.err.println("Failed to start Apache DS");
|
System.err.println("Failed to start Apache DS");
|
||||||
@ -182,7 +196,7 @@ public class LdapTestServer {
|
|||||||
try {
|
try {
|
||||||
serverContext.createSubcontext( "cn="+cn+",ou=groups", group );
|
serverContext.createSubcontext( "cn="+cn+",ou=groups", group );
|
||||||
} catch(NameAlreadyBoundException ignore) {
|
} catch(NameAlreadyBoundException ignore) {
|
||||||
System.out.println(" group " + cn + " already exists.");
|
// System.out.println(" group " + cn + " already exists.");
|
||||||
} catch (NamingException ne) {
|
} catch (NamingException ne) {
|
||||||
System.err.println("Failed to create group.");
|
System.err.println("Failed to create group.");
|
||||||
ne.printStackTrace();
|
ne.printStackTrace();
|
||||||
@ -190,6 +204,8 @@ public class LdapTestServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initConfiguration() {
|
private void initConfiguration() {
|
||||||
|
|
||||||
|
// Create the partition for the acegi tests
|
||||||
MutableDirectoryPartitionConfiguration acegiDit = new MutableDirectoryPartitionConfiguration();
|
MutableDirectoryPartitionConfiguration acegiDit = new MutableDirectoryPartitionConfiguration();
|
||||||
acegiDit.setName("acegisecurity");
|
acegiDit.setName("acegisecurity");
|
||||||
acegiDit.setSuffix("dc=acegisecurity,dc=org");
|
acegiDit.setSuffix("dc=acegisecurity,dc=org");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user