Skip to content

Commit

Permalink
Removes accessor of TestDirectory outside Rule context
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Sep 20, 2016
1 parent 1107550 commit 7a4fc7b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Expand Up @@ -247,11 +247,7 @@ private void evaluateClassBaseTestFolder( )
}
}

/**
* This method can be used outside the context of a Rule as a utility. It will return something like:
* {@code component/target/test-data/org.neo4j.location.of.my.test.Clazz/}
*/
public static File testDataDirectoryOf( FileSystemAbstraction fs, Class<?> owningTest, boolean clean )
private static File testDataDirectoryOf( FileSystemAbstraction fs, Class<?> owningTest, boolean clean )
throws IOException
{
File testData = new File( locateTarget( owningTest ), "test-data" );
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -64,11 +65,13 @@
@RunWith( Parameterized.class )
public class StoreNodeRelationshipCursorTest
{

private static final long FIRST_OWNING_NODE = 1;
private static final long SECOND_OWNING_NODE = 2;
private static final int TYPE = 0;

@ClassRule
public static TestDirectory directory = TestDirectory.testDirectory( StoreNodeRelationshipCursorTest.class );

private static PageCache pageCache;
private static NeoStores neoStores;

Expand All @@ -91,13 +94,13 @@ public static Iterable<Object[]> parameters()
}

@BeforeClass
public static void setupStores() throws IOException
public static void setupStores()
{
File directory = TestDirectory.testDataDirectoryOf( REAL_FS, StoreNodeRelationshipCursor.class, true );
File storeDir = directory.absolutePath();
pageCache = new ConfiguringPageCacheFactory( REAL_FS,
Config.defaults().augment( stringMap( pagecache_memory.name(), "8m" ) ), NULL, NullLog.getInstance() )
.getOrCreatePageCache();
StoreFactory storeFactory = new StoreFactory( directory, pageCache, REAL_FS, NullLogProvider.getInstance() );
StoreFactory storeFactory = new StoreFactory( storeDir, pageCache, REAL_FS, NullLogProvider.getInstance() );
neoStores = storeFactory.openAllNeoStores( true );
}

Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -195,7 +196,9 @@ private enum RelTypes implements RelationshipType
private static final FileSystemAbstraction fs = REAL_FS;

@Rule
public TestDirectory storeDir = TestDirectory.testDirectory();
public TestDirectory storeDir = TestDirectory.testDirectory( getClass() );
@ClassRule
public static TestDirectory globalStoreDir = TestDirectory.testDirectory( BatchInsertTest.class );
@Rule
public final PageCacheRule pageCacheRule = new PageCacheRule();

Expand All @@ -207,8 +210,7 @@ public static void startGlobalInserter() throws IOException
// Global inserter can be used in tests which simply want to verify "local" behaviour,
// e.g. create a node with some properties and read them back.
globalInserter = BatchInserters.inserter(
TestDirectory.testDataDirectoryOf( fs, BatchInsertTest.class, true ),
fs, stringMap() );
globalStoreDir.directory( "global" ), fs, stringMap() );
}

@After
Expand Down

0 comments on commit 7a4fc7b

Please sign in to comment.