use of org.neo4j.harness.ServerControls in project neo4j by neo4j.
the class EnterpriseInProcessServerBuilderTest method shouldLaunchAServerInSpecifiedDirectory.
@Test
public void shouldLaunchAServerInSpecifiedDirectory() throws Exception {
// Given
File workDir = new File(testDir.directory(), "specific");
workDir.mkdir();
// When
try (ServerControls server = getTestServerBuilder(workDir).newServer()) {
// Then
assertThat(HTTP.GET(server.httpURI().toString()).status(), equalTo(200));
assertThat(workDir.list().length, equalTo(1));
}
// And after it's been closed, it should've cleaned up after itself.
assertThat(Arrays.toString(workDir.list()), workDir.list().length, equalTo(0));
}
use of org.neo4j.harness.ServerControls in project neo4j by neo4j.
the class TransactionTerminationIT method terminateSingleInstanceRestTransactionThatWaitsForLock.
@Test
public void terminateSingleInstanceRestTransactionThatWaitsForLock() throws Exception {
ServerControls server = cleanupRule.add(TestServerBuilders.newInProcessBuilder().withConfig(GraphDatabaseSettings.auth_enabled, Settings.FALSE).withConfig(GraphDatabaseFacadeFactory.Configuration.lock_manager, lockManagerName).newServer());
GraphDatabaseService db = server.graph();
HTTP.Builder http = withBaseUri(server.httpURI().toString());
long value1 = 1L;
long value2 = 2L;
createNode(db);
Response tx1 = startTx(http);
Response tx2 = startTx(http);
assertNumberOfActiveTransactions(2, db);
Response update1 = executeUpdateStatement(tx1, value1, http);
assertThat(update1.status(), equalTo(200));
assertThat(update1, containsNoErrors());
CountDownLatch latch = new CountDownLatch(1);
Future<?> tx2Result = executeInSeparateThread("tx2", () -> {
latch.countDown();
Response update2 = executeUpdateStatement(tx2, value2, http);
assertTxWasTerminated(update2);
});
await(latch);
sleepForAWhile();
terminate(tx2, http);
commit(tx1, http);
Response update3 = executeUpdateStatement(tx2, value2, http);
assertThat(update3.status(), equalTo(404));
tx2Result.get(1, TimeUnit.MINUTES);
assertNodeExists(db, value1);
}
Aggregations