Search in sources :

Example 1 with ServerControls

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));
}
Also used : ServerControls(org.neo4j.harness.ServerControls) File(java.io.File) Test(org.junit.Test)

Example 2 with ServerControls

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);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HTTP(org.neo4j.test.server.HTTP) ServerControls(org.neo4j.harness.ServerControls) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ServerControls (org.neo4j.harness.ServerControls)2 File (java.io.File)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 HTTP (org.neo4j.test.server.HTTP)1 Response (org.neo4j.test.server.HTTP.Response)1