Skip to content

Commit

Permalink
Moves file system rules to neo4j-io component
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Dec 11, 2016
1 parent 120b304 commit 6c0fc25
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 17 deletions.
Expand Up @@ -55,7 +55,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.test.rule.fs.EphemeralFileSystemRule.shutdownDbAction;

public class ConsistencyCheckToolTest
{
Expand Down Expand Up @@ -196,7 +195,7 @@ private void createGraphDbAndKillIt() throws Exception
tx.success();
}

fs.snapshot( shutdownDbAction( db ) );
fs.snapshot( () -> db.shutdown() );
}

private void runConsistencyCheckToolWith( FileSystemAbstraction fileSystem, String... args )
Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.io.IOException;
import java.util.function.Supplier;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;

Expand Down Expand Up @@ -73,11 +72,6 @@ public void clear() throws Exception
fs = new EphemeralFileSystemAbstraction();
}

public static Runnable shutdownDbAction( final GraphDatabaseService db )
{
return () -> db.shutdown();
}

@Override
public int hashCode()
{
Expand Down
Expand Up @@ -59,7 +59,6 @@
import static org.neo4j.kernel.configuration.Settings.FALSE;
import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasProperty;
import static org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx;
import static org.neo4j.test.rule.fs.EphemeralFileSystemRule.shutdownDbAction;

/**
* Test for making sure that slow id generator rebuild is exercised
Expand All @@ -86,7 +85,7 @@ public void crashAndRebuildSlowWithDynamicStringDeletions() throws Exception

assertThat( checksumBefore, Matchers.equalTo( checksumBefore2 ) );

EphemeralFileSystemAbstraction snapshot = fs.snapshot( shutdownDbAction( db ) );
EphemeralFileSystemAbstraction snapshot = fs.snapshot( () -> db.shutdown() );

long snapshotChecksum = snapshot.checksum();
if ( snapshotChecksum != checksumBefore )
Expand Down
Expand Up @@ -32,8 +32,6 @@
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.fs.EphemeralFileSystemRule;

import static org.neo4j.test.rule.fs.EphemeralFileSystemRule.shutdownDbAction;

public class TestTxEntries
{
private final File storeDir = new File("dir");
Expand All @@ -50,7 +48,7 @@ public void testStartEntryWrittenOnceOnRollback() throws Exception
{
final GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fs.get() ).newImpermanentDatabase( storeDir );
createSomeTransactions( db );
EphemeralFileSystemAbstraction snapshot = fs.snapshot( shutdownDbAction( db ) );
EphemeralFileSystemAbstraction snapshot = fs.snapshot( () -> db.shutdown() );

new TestGraphDatabaseFactory().setFileSystem( snapshot ).newImpermanentDatabase( storeDir ).shutdown();
}
Expand Down
Expand Up @@ -45,7 +45,6 @@

import static org.junit.Assert.assertEquals;
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.test.rule.fs.EphemeralFileSystemRule.shutdownDbAction;

public class CountsStoreRecoveryTest
{
Expand Down Expand Up @@ -108,7 +107,8 @@ private void checkPoint() throws IOException

private void crashAndRestart() throws Exception
{
FileSystemAbstraction uncleanFs = fsRule.snapshot( shutdownDbAction( db ) );
final GraphDatabaseService db1 = db;
FileSystemAbstraction uncleanFs = fsRule.snapshot( () -> db1.shutdown() );
db = databaseFactory( uncleanFs, indexProvider ).newImpermanentDatabase();
}

Expand Down
Expand Up @@ -31,6 +31,7 @@
import java.util.Collections;
import java.util.List;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.NotFoundException;
Expand All @@ -56,7 +57,6 @@
import static org.junit.Assert.fail;
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.register.Registers.newDoubleLongRegister;
import static org.neo4j.test.rule.fs.EphemeralFileSystemRule.shutdownDbAction;


/**
Expand Down Expand Up @@ -338,7 +338,8 @@ private void setProperty( Node node, String key, Object value )
@SuppressWarnings("deprecation")
private void crashAndRestart( InMemoryIndexProvider indexProvider ) throws Exception
{
FileSystemAbstraction uncleanFs = fsRule.snapshot( shutdownDbAction( db ) );
final GraphDatabaseService db1 = db;
FileSystemAbstraction uncleanFs = fsRule.snapshot( () -> db1.shutdown() );
db = (GraphDatabaseAPI) databaseFactory( uncleanFs, indexProvider ).newImpermanentDatabase();
}
}

0 comments on commit 6c0fc25

Please sign in to comment.