Skip to content

Commit

Permalink
Close store file channel
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarW committed Sep 24, 2018
1 parent 8b139f8 commit 628d48c
Showing 1 changed file with 10 additions and 11 deletions.
Expand Up @@ -30,12 +30,12 @@
import java.io.IOException; import java.io.IOException;


import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.io.layout.DatabaseLayout;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles; import org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles;
import org.neo4j.test.rule.PageCacheRule; import org.neo4j.test.rule.PageCacheRule;
import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;


import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
Expand All @@ -45,23 +45,22 @@ public class CommitStateHelperTest
@Rule @Rule
public final TestDirectory testDirectory = TestDirectory.testDirectory(); public final TestDirectory testDirectory = TestDirectory.testDirectory();
@Rule @Rule
public final DefaultFileSystemRule fsr = new DefaultFileSystemRule();
@Rule
public final PageCacheRule pageCacheRule = new PageCacheRule(); public final PageCacheRule pageCacheRule = new PageCacheRule();


private Config config; private Config config;
private CommitStateHelper commitStateHelper; private CommitStateHelper commitStateHelper;
private File storeDir;
private DatabaseLayout databaseLayout; private DatabaseLayout databaseLayout;
private FileSystemAbstraction fsa;


@Before @Before
public void setUp() public void setUp()
{ {
File txLogLocation = new File( testDirectory.directory(), "txLogLocation" ); File txLogLocation = new File( testDirectory.directory(), "txLogLocation" );
config = Config.builder().withSetting( GraphDatabaseSettings.logical_logs_location, txLogLocation.getAbsolutePath() ).build(); config = Config.builder().withSetting( GraphDatabaseSettings.logical_logs_location, txLogLocation.getAbsolutePath() ).build();
storeDir = testDirectory.storeDir(); File storeDir = testDirectory.storeDir();
databaseLayout = DatabaseLayout.of( storeDir, config.get( GraphDatabaseSettings.active_database ) ); databaseLayout = DatabaseLayout.of( storeDir, config.get( GraphDatabaseSettings.active_database ) );
commitStateHelper = new CommitStateHelper( pageCacheRule.getPageCache( fsr ), fsr, config ); fsa = testDirectory.getFileSystem();
commitStateHelper = new CommitStateHelper( pageCacheRule.getPageCache( fsa ), fsa, config );
} }


@Test @Test
Expand All @@ -76,7 +75,7 @@ public void shouldNotHaveTxLogsIfDirectoryDoesNotExist() throws IOException
public void shouldNotHaveTxLogsIfDirectoryIsEmpty() throws IOException public void shouldNotHaveTxLogsIfDirectoryIsEmpty() throws IOException
{ {
File txDir = config.get( GraphDatabaseSettings.logical_logs_location ); File txDir = config.get( GraphDatabaseSettings.logical_logs_location );
txDir.mkdir(); fsa.mkdir( txDir );


assertFalse( commitStateHelper.hasTxLogs( databaseLayout ) ); assertFalse( commitStateHelper.hasTxLogs( databaseLayout ) );
} }
Expand All @@ -85,9 +84,9 @@ public void shouldNotHaveTxLogsIfDirectoryIsEmpty() throws IOException
public void shouldNotHaveTxLogsIfDirectoryHasFilesWithIncorrectName() throws IOException public void shouldNotHaveTxLogsIfDirectoryHasFilesWithIncorrectName() throws IOException
{ {
File txDir = config.get( GraphDatabaseSettings.logical_logs_location ); File txDir = config.get( GraphDatabaseSettings.logical_logs_location );
txDir.mkdir(); fsa.mkdir( txDir );


fsr.create( new File( txDir, "foo.bar" ) ); fsa.create( new File( txDir, "foo.bar" ) ).close();


assertFalse( commitStateHelper.hasTxLogs( databaseLayout ) ); assertFalse( commitStateHelper.hasTxLogs( databaseLayout ) );
} }
Expand All @@ -96,8 +95,8 @@ public void shouldNotHaveTxLogsIfDirectoryHasFilesWithIncorrectName() throws IOE
public void shouldHaveTxLogsIfDirectoryHasTxFile() throws IOException public void shouldHaveTxLogsIfDirectoryHasTxFile() throws IOException
{ {
File txDir = config.get( GraphDatabaseSettings.logical_logs_location ); File txDir = config.get( GraphDatabaseSettings.logical_logs_location );
txDir.mkdir(); fsa.mkdir( txDir );
fsr.create( new File( txDir, TransactionLogFiles.DEFAULT_NAME + ".0" ) ); fsa.create( new File( txDir, TransactionLogFiles.DEFAULT_NAME + ".0" ) ).close();


assertTrue( commitStateHelper.hasTxLogs( databaseLayout ) ); assertTrue( commitStateHelper.hasTxLogs( databaseLayout ) );
} }
Expand Down

0 comments on commit 628d48c

Please sign in to comment.