Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with deletion of chronicle file #32

Closed
pwielgolaski opened this issue Dec 2, 2013 · 1 comment
Closed

Issue with deletion of chronicle file #32

pwielgolaski opened this issue Dec 2, 2013 · 1 comment
Assignees

Comments

@pwielgolaski
Copy link

I noticed that there is issue with delete operation for chronicle files, what's complicating tests (problem with creating namy test in one unit for the same chronicle)

it is test example

public class CloseChronicleTest {

    @Test
    public void simpleChronicleTest1() throws IOException {
        final String basePath = "simpleTest";
        deleteAndAssert(basePath);
        IndexedChronicle chronicle = new IndexedChronicle(basePath);
        chronicle.close();
        deleteAndAssert(basePath);
    }

    @Test
    public void simpleChronicleTest2() throws IOException {
        final String basePath = "simpleTest";
        deleteAndAssert(basePath);
        IndexedChronicle chronicle = new IndexedChronicle(basePath);
        ExcerptAppender appender = chronicle.createAppender();
        appender.close();
        chronicle.close();
        // it must be called because of JDK-6558368
        System.gc();
        deleteAndAssert(basePath);
    }

    private void deleteAndAssert(String basePath) throws IOException {
        for (String name : new String[] { basePath + ".data", basePath + ".index" }) {
            File file = new File(name);
            if (file.exists()) {
                Assert.assertTrue(file.getCanonicalPath(), file.delete());
            }
        }
    }
}

it seems that it could be working, but we need to nullified mappedbuffer in two classes.
What do you think about it? IMHO it would make testing easier.
Check out:
https://github.com/pwielgolaski/Java-Chronicle/commit/2735c21d277c55252e9cde6a4e26fafc98997227

lburgazzoli added a commit to lburgazzoli/Chronicle-Queue that referenced this issue Dec 29, 2014
@lburgazzoli lburgazzoli self-assigned this Dec 29, 2014
@lburgazzoli
Copy link
Contributor

Resource related issues have already been solved however I've added your test case to our tests.
If you easilly want to define a per-test path you can do something like:

public class MyTests {
    @Rule
    public final TestName testName = new TestName();

    public void test1() throws IOException {
        final String basePath =  "/tmp/chronicleTest-" + testName.getMethodName();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants