Browse Source

Pass apache-ds temp working directory as a system property through the surefire plugin.

Luke Taylor 18 years ago
parent
commit
5464678355
2 changed files with 14 additions and 9 deletions
  1. 6 6
      core/src/test/java/org/acegisecurity/ldap/LdapTestServer.java
  2. 8 3
      pom.xml

+ 6 - 6
core/src/test/java/org/acegisecurity/ldap/LdapTestServer.java

@@ -207,16 +207,16 @@ public class LdapTestServer {
     private void startLdapServer() {
         cfg = new MutableStartupConfiguration();
 
-        // Attempt to use the maven target directory for the apache ds store.
-        // This doesn't work at the moment - need to find out if we can access maven properties somehow.
+        // Attempt to use the maven target directory for the apache ds store. Property is passed
+        // through surefire plugin setup in pom.xml.
 
-        String tempDirectory = System.getProperty("maven.build.dir");
+        String apacheWorkDir = System.getProperty("apacheDSWorkDir");
 
-        if(tempDirectory == null) {
-            tempDirectory = System.getProperty("java.io.tmpdir");
+        if(apacheWorkDir == null) {
+            apacheWorkDir = System.getProperty("java.io.tmpdir" + File.separator + "apacheds-work");
         }
 
-        File workingDir = new File(tempDirectory + File.separator + "apacheds-work");
+        File workingDir = new File(apacheWorkDir);
 
         // Delete any previous contents (often not compatible between apache-ds versions).
         deleteDir(workingDir);

+ 8 - 3
pom.xml

@@ -1,6 +1,4 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.acegisecurity</groupId>
   <artifactId>acegi-security-parent</artifactId>
@@ -250,6 +248,13 @@
             <exclude>**/Abstract*</exclude>
           </excludes>
           <forkMode>once</forkMode>
+          <systemProperties>
+            <!-- The working directory for the embedded apache Ldap test server --> 
+            <property>
+              <name>apacheDSWorkDir</name>
+              <value>${basedir}/target/apacheds-work</value>
+            </property>
+          </systemProperties>
         </configuration>
       </plugin>
       <plugin>