use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class RebuildCountsTest method restart.
private void restart(FileSystemAbstraction fs) throws IOException {
if (db != null) {
db.shutdown();
}
fs.mkdirs(storeDir);
TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();
db = dbFactory.setUserLogProvider(userLogProvider).setInternalLogProvider(internalLogProvider).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).addKernelExtension(new InMemoryIndexProviderFactory(indexProvider)).newImpermanentDatabaseBuilder(storeDir).setConfig(index_background_sampling_enabled, "false").newGraphDatabase();
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class DatabaseStartupTest method startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed.
@Test
public void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() throws Throwable {
// given
// create a store
File storeDir = testDirectory.graphDbDir();
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
db.shutdown();
// mess up the version in the metadatastore
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
MetaDataStore.setRecord(pageCache, new File(storeDir, MetaDataStore.DEFAULT_NAME), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong("bad"));
}
// when
try {
new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
fail("It should have failed.");
} catch (RuntimeException ex) {
// then
assertTrue(ex.getCause() instanceof LifecycleException);
assertTrue(ex.getCause().getCause() instanceof UpgradeNotAllowedByConfigurationException);
assertEquals("Failed to start Neo4j with an older data store version. To enable automatic upgrade, " + "please set configuration parameter \"dbms.allow_format_migration=true\"", ex.getCause().getCause().getMessage());
}
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method populateDbAndIndexes.
private void populateDbAndIndexes(int nodeCount, boolean multiThreaded) throws InterruptedException {
final GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(directory.graphDbDir()).setConfig(GraphDatabaseSettings.multi_threaded_schema_index_population_enabled, multiThreaded + "").newGraphDatabase();
try {
createIndexes(db);
final AtomicBoolean end = new AtomicBoolean();
ExecutorService executor = cleanup.add(Executors.newCachedThreadPool());
for (int i = 0; i < 10; i++) {
executor.submit(() -> {
Randoms random = new Randoms();
while (!end.get()) {
changeRandomNode(db, nodeCount, random);
}
});
}
while (!indexesAreOnline(db)) {
Thread.sleep(100);
}
end.set(true);
executor.shutdown();
executor.awaitTermination(10, SECONDS);
} finally {
db.shutdown();
}
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class PagingTraversalTest method startDatabase.
@Before
public void startDatabase() throws IOException {
graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
database = new WrappedDatabase(graph);
helper = new GraphDbHelper(database);
EntityOutputFormat output = new EntityOutputFormat(new JsonFormat(), URI.create(BASE_URI), null);
leaseManager = new LeaseManager(Clocks.fakeClock());
service = new RestfulGraphDatabase(new JsonFormat(), output, new DatabaseActions(leaseManager, true, database.getGraph()), null);
service = new TransactionWrappingRestfulGraphDatabase(graph, service);
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class DatabaseActionsTest method createDb.
@BeforeClass
public static void createDb() throws IOException {
graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
database = new WrappedDatabase(graph);
graphdbHelper = new GraphDbHelper(database);
actions = new TransactionWrappedDatabaseActions(new LeaseManager(Clocks.fakeClock()), database.getGraph());
}
Aggregations