use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class EmbeddedBuiltInProceduresInteractionTest method shouldNotKillQueryIfNotAuthenticated.
@Test
public void shouldNotKillQueryIfNotAuthenticated() throws Throwable {
EnterpriseSecurityContext authy = createFakeAnonymousEnterpriseSecurityContext();
GraphDatabaseFacade graph = neo.getLocalGraph();
DoubleLatch latch = new DoubleLatch(2);
ThreadedTransaction<EnterpriseSecurityContext> read = new ThreadedTransaction<>(neo, latch);
String query = read.execute(threading, authy, "UNWIND [1,2,3] AS x RETURN x");
latch.startAndWaitForAllToStart();
String id = extractQueryId(query);
try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.explicit, AnonymousContext.none())) {
graph.execute(tx, "CALL dbms.killQuery('" + id + "')", Collections.emptyMap());
throw new AssertionError("Expected exception to be thrown");
} catch (QueryExecutionException e) {
assertThat(e.getMessage(), containsString(PERMISSION_DENIED));
}
latch.finishAndWaitForAllToFinish();
read.closeAndAssertSuccess();
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class TestFabricTransaction method execute.
@Override
public Result execute(String query, Map<String, Object> parameters) throws QueryExecutionException {
var ctx = new TestFabricTransactionalContext(kernelInternalTransaction);
var params = ValueUtils.asParameterMapValue(parameters);
var result = new ResultSubscriber(ctx, ctx.valueMapper());
try {
BoltQueryExecution boltQueryExecution = fabricTransaction.executeQuery(query, params, false, result);
result.init(boltQueryExecution.getQueryExecution());
} catch (FabricException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new QueryExecutionException(e.getMessage(), e, e.status().code().serialize());
}
} catch (QueryExecutionKernelException | Neo4jException e) {
throw new QueryExecutionException(e.getMessage(), e, e.status().code().serialize());
}
return result;
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class NotificationAcceptanceTest method shouldGetErrorWhenUsingCreateUniqueWhenCypherVersionIs3_5.
@Test
void shouldGetErrorWhenUsingCreateUniqueWhenCypherVersionIs3_5() {
// when
QueryExecutionException exception = assertThrows(QueryExecutionException.class, () -> db.executeTransactionally("CYPHER 3.5 MATCH (b) WITH b LIMIT 1 CREATE UNIQUE (b)-[:REL]->()"));
assertThat(exception.getStatusCode(), containsString("SyntaxError"));
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class PropertyConstraintsStressIT method createPropertyExistenceConstraintCommand.
private static WorkerCommand<Object, Boolean> createPropertyExistenceConstraintCommand(final GraphDatabaseService db, final String query) {
return new WorkerCommand<Object, Boolean>() {
@Override
public Boolean doWork(Object state) throws Exception {
boolean constraintCreationFailed = false;
try (Transaction tx = db.beginTx()) {
db.execute(query);
tx.success();
} catch (QueryExecutionException e) {
System.out.println("Constraint failed: " + e.getMessage());
if (Exceptions.rootCause(e) instanceof ConstraintValidationException) {
// Unable to create constraint since it is not consistent with existing data
constraintCreationFailed = true;
} else {
throw e;
}
}
if (!constraintCreationFailed) {
System.out.println("Constraint created: " + query);
}
return constraintCreationFailed;
}
};
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class AbstractConstraintCreationIT method shouldNotLeaveAnyStateBehindAfterFailingToCreateConstraint.
@Test
public void shouldNotLeaveAnyStateBehindAfterFailingToCreateConstraint() throws Exception {
// given
try (Transaction tx = db.beginTx()) {
createOffendingDataInRunningTx(db);
tx.success();
}
// when
try (Transaction tx = db.beginTx()) {
createConstraintInRunningTx(db, KEY, PROP);
tx.success();
fail("expected failure");
} catch (QueryExecutionException e) {
assertThat(e.getMessage(), startsWith("Unable to create CONSTRAINT"));
}
// then
try (Transaction tx = db.beginTx()) {
assertEquals(Collections.<ConstraintDefinition>emptyList(), Iterables.asList(db.schema().getConstraints()));
assertEquals(Collections.<IndexDefinition, Schema.IndexState>emptyMap(), indexesWithState(db.schema()));
tx.success();
}
}
Aggregations