java.lang.RuntimeException:java.nio.file.DirectoryNotEmptyException

时间:2017-03-24 05:22:43

标签: java neo4j java-io

执行Neo4j测试用例时。我面临以下错误。

java.lang.RuntimeException: java.nio.file.DirectoryNotEmptyException:test-data/org.neo4j.test.ha.ClusterTest/D4FA83E7CD83F51509461D8F437E0481/testConflictingHaPorts
        at org.neo4j.test.rule.TestDirectory.complete(TestDirectory.java:211)
        at org.neo4j.test.rule.TestDirectory.access$200(TestDirectory.java:57)
        at org.neo4j.test.rule.TestDirectory$1.evaluate(TestDirectory.java:113)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) 

看起来它无法删除目录,因此面临上述执行。用户拥有所有权限。

下面的代码段用于删除目录

 public void evaluate() throws Throwable
            {
                directory = new File( new File( new File( new File( "target" ), "test-data" ),
                                                description.getClassName() ), description.getMethodName() );
                delete( directory );
                directory.mkdirs();
                boolean success = false;
                try
                {
                    base.evaluate();
                    success = true;
                }
                finally
                {
                    if ( success )
                    {
                        delete( directory );
                        delete( directory.getParentFile() ); // works if it's empty
                    }
                }
            }

0 个答案:

没有答案