use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class HAClusterStartupIT method createSomeData.
private static void createSomeData(GraphDatabaseService oldMaster) {
try (Transaction tx = oldMaster.beginTx()) {
oldMaster.createNode();
tx.success();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class ProcedureIT method shouldGiveHelpfulErrorOnExceptionMidStream.
@Test
public void shouldGiveHelpfulErrorOnExceptionMidStream() throws Throwable {
// run in tx to avoid having to wait for tx rollback on shutdown
try (Transaction ignore = db.beginTx()) {
Result result = db.execute("CALL org.neo4j.procedure.throwsExceptionInStream");
// Expect
exception.expect(QueryExecutionException.class);
exception.expectMessage("Failed to call procedure `org.neo4j.procedure.throwsExceptionInStream() :: (someVal :: INTEGER?)" + "`: " + "Kaboom");
// When
result.next();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class ProcedureIT method shouldGiveNiceErrorMessageOnWrongStaticType.
@Test
public void shouldGiveNiceErrorMessageOnWrongStaticType() throws Throwable {
//Expect
exception.expect(QueryExecutionException.class);
exception.expectMessage("Type mismatch: expected Integer but was String (line 1, column 41 (offset: 40))");
// When
try (Transaction ignore = db.beginTx()) {
//Make sure argument here is not auto parameterized away as that will drop all type information on the floor
db.execute("CALL org.neo4j.procedure.simpleArgument('42')");
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningTransaction.
@Test
public void terminateLongRunningTransaction() {
GraphDatabaseAPI database = startDatabaseWithTimeout();
try (Transaction transaction = database.beginTx()) {
fakeClock.forward(3, TimeUnit.SECONDS);
transaction.success();
database.createNode();
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException e) {
assertThat(e.getMessage(), startsWith("Transaction timeout."));
assertEquals(e.status(), Status.Transaction.TransactionTimedOut);
}
assertDatabaseDoesNotHaveNodes(database);
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningQueryTransaction.
@Test
public void terminateLongRunningQueryTransaction() {
GraphDatabaseAPI database = startDatabaseWithTimeout();
try (Transaction transaction = database.beginTx()) {
fakeClock.forward(3, TimeUnit.SECONDS);
transaction.success();
database.execute("create (n)");
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException e) {
assertThat(e.getMessage(), startsWith("Transaction timeout."));
}
assertDatabaseDoesNotHaveNodes(database);
}
Aggregations