AbstractLdapTestUnit fails with more than one @Test when partition located
within service's working directory
-------------------------------------------------------------------------------------------------------------
Key: DIRSERVER-1575
URL: https://issues.apache.org/jira/browse/DIRSERVER-1575
Project: Directory ApacheDS
Issue Type: Bug
Affects Versions: 1.5.7
Environment: Windows 7
JDK 1.5.0_22, also happens with 1.6.0_21
Reporter: Andrew Swan
Priority: Minor
Problem
~~~~~~~
In my subclass of AbstractLdapTestUnit, I'm creating a custom Partition for my
test LDAP entries. However if I locate this partition within the
DirectoryService's working directory, and my test case has more than one @Test
method, then after the test methods run (successfully), the test case fails
with this error:
java.io.IOException: Unable to delete file:
E:\Temp\server-work-default02f53ef4-636e-4edf-a812-0a76ce27e399\myPartition\objectClass.lg
at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1390)
at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1044)
at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:977)
at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1381)
at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1044)
at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:977)
at
org.apache.directory.server.core.integ.FrameworkRunner.run(FrameworkRunner.java:259)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Failing Test
~~~~~~~~~
package au.com.bisinfo.ldap;
import java.io.File;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(FrameworkRunner.class)
@CreateLdapServer(transports = @CreateTransport(protocol = "ldap"))
public class ApacheBugTest extends AbstractLdapTestUnit {
@Before
public void setUp() throws Exception {
final File partitionDirectory =
new File(service.getWorkingDirectory(), "myPartition");
final JdbmPartition partition = new JdbmPartition();
partition.setId("anything");
partition.setPartitionDir(partitionDirectory);
partition.setSchemaManager(service.getSchemaManager());
partition.setSuffix("dc=example,dc=com"); // anything
service.addPartition(partition);
}
@Test public void test() { System.out.println("Dummy test"); }
@Test public void test2() { System.out.println("Dummy test 2"); }
}
Maven 2 Dependencies
~~~~~~~~~~~~~~~~~~~
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-test-framework</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-integ</artifactId>
<version>1.5.7</version>
</dependency>
Workarounds
~~~~~~~~~~~
I can make this test pass by either:
* Only having one test method per test case (not very convenient), or
* Locating the partition somewhere outside the working directory of the
DirectoryService. But even in this case, I still get the "Unable to delete
file" error if I try to clean up the partition directory from an @After or
@AfterClass method.
Ideas
~~~~
>From looking at the source for jdbm.recman.TransactionManager, objectClass.lg
>is a JDBM log file. Is this bug simply a case of that file not being closed
>when it should be (e.g. when the DirectoryService shuts down)? Is this bug
>related to DIRSERVER-1348 in some way?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.