use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class UserFunctionIT method setUp.
@Before
public void setUp() throws IOException {
exceptionsInFunction.clear();
new JarBuilder().createJarFor(plugins.newFile("myFunctions.jar"), ClassWithFunctions.class);
db = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.plugin_dir, plugins.getRoot().getAbsolutePath()).newGraphDatabase();
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class DiagnosticsLoggingTest method shouldSeeExpectedDiagnostics.
@Test
public void shouldSeeExpectedDiagnostics() {
AssertableLogProvider logProvider = new AssertableLogProvider();
GraphDatabaseService db = new TestGraphDatabaseFactory().setInternalLogProvider(logProvider).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.dump_configuration, Settings.TRUE).setConfig(GraphDatabaseSettings.pagecache_memory, "4M").newGraphDatabase();
// THEN we should have logged
logProvider.assertContainsMessageContaining("Network information");
logProvider.assertContainsMessageContaining("Disk space on partition");
logProvider.assertContainsMessageContaining("Local timezone");
// page cache info
logProvider.assertContainsMessageContaining("Page cache size: 4 MiB");
// neostore records
for (MetaDataStore.Position position : MetaDataStore.Position.values()) {
logProvider.assertContainsMessageContaining(position.name());
}
// transaction log info
logProvider.assertContainsMessageContaining("Transaction log");
db.shutdown();
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceTest method givenDatabaseAndStartedTxWhenShutdownThenWaitForTxToFinish.
@Test
public void givenDatabaseAndStartedTxWhenShutdownThenWaitForTxToFinish() throws Exception {
// Given
final GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
// When
Barrier.Control barrier = new Barrier.Control();
Future<Object> txFuture = t2.execute(state -> {
try (Transaction tx = db.beginTx()) {
barrier.reached();
db.createNode();
tx.success();
}
return null;
});
// i.e. wait for transaction to start
barrier.await();
// now there's a transaction open, blocked on continueTxSignal
Future<Object> shutdownFuture = t3.execute(state -> {
db.shutdown();
return null;
});
t3.get().waitUntilWaiting(location -> location.isAt(DatabaseAvailability.class, "stop"));
barrier.release();
try {
txFuture.get();
} catch (ExecutionException e) {
// expected
}
shutdownFuture.get();
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceTest method terminateNestedTransactionThrowsExceptionOnNextNestedOperationMultiThreadedVersion.
@Test
public void terminateNestedTransactionThrowsExceptionOnNextNestedOperationMultiThreadedVersion() throws Exception {
// Given
final GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
try {
// When
final CountDownLatch txSet = new CountDownLatch(1);
final CountDownLatch terminated = new CountDownLatch(1);
final Transaction[] outer = { null };
final Exception[] threadFail = { null };
Thread worker = new Thread(() -> {
try (Transaction inner = db.beginTx()) {
outer[0] = inner;
txSet.countDown();
terminated.await();
db.createNode();
fail("should have failed earlier");
} catch (Exception e) {
threadFail[0] = e;
}
});
worker.start();
txSet.await();
outer[0].terminate();
terminated.countDown();
worker.join();
assertThat(threadFail[0], instanceOf(TransactionTerminatedException.class));
} finally {
db.shutdown();
}
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphDatabaseServiceTest method givenDatabaseAndStartedTxWhenShutdownAndStartNewTxThenBeginTxTimesOut.
@Test
public void givenDatabaseAndStartedTxWhenShutdownAndStartNewTxThenBeginTxTimesOut() throws Exception {
// Given
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
// When
Barrier.Control barrier = new Barrier.Control();
t2.execute(state -> {
try (Transaction tx = db.beginTx()) {
barrier.reached();
}
return null;
});
barrier.await();
Future<Object> shutdownFuture = t3.execute(state -> {
db.shutdown();
return null;
});
t3.get().waitUntilWaiting(location -> location.isAt(DatabaseAvailability.class, "stop"));
// <-- this triggers t2 to continue its transaction
barrier.release();
shutdownFuture.get();
try {
db.beginTx();
fail("Should fail");
} catch (DatabaseShutdownException e) {
//THEN good
}
}
Aggregations