use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldRunSimpleReadOnlyProcedure.
@Test
void shouldRunSimpleReadOnlyProcedure() throws Throwable {
// Given
CallableProcedure proc = compile(SingleReadOnlyProcedure.class).get(0);
// When
RawIterator<AnyValue[], ProcedureException> out = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(out)).containsExactly(new AnyValue[] { stringValue("Bonnie") }, new AnyValue[] { stringValue("Clyde") });
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldGiveHelpfulErrorOnNoPublicConstructor.
@Test
void shouldGiveHelpfulErrorOnNoPublicConstructor() {
ProcedureException exception = assertThrows(ProcedureException.class, () -> compile(PrivateConstructorProcedure.class));
assertThat(exception.getMessage()).isEqualTo("Unable to find a usable public no-argument constructor in the class `PrivateConstructorProcedure`. Please add " + "a valid, public constructor, recompile the class and try again.");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldCloseResourcesAndGiveHelpfulErrorOnMidStreamException.
@Test
void shouldCloseResourcesAndGiveHelpfulErrorOnMidStreamException() throws Throwable {
// Given
CallableProcedure proc = compile(ProcedureThatThrowsNullMsgExceptionMidStream.class).get(0);
ProcedureException exception = assertThrows(ProcedureException.class, () -> {
RawIterator<AnyValue[], ProcedureException> stream = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
if (stream.hasNext()) {
stream.next();
}
});
assertThat(exception.getMessage()).isEqualTo("Failed to invoke procedure `org.neo4j.procedure.impl.throwsInStream`: Caused by: java.lang.IndexOutOfBoundsException");
// Expect that we get a suppressed exception from Stream.onClose (which also verifies that we actually call
// onClose on the first exception)
assertThat(exception.getSuppressed()[0]).hasRootCauseInstanceOf(ExceptionDuringClose.class);
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProcedureTest method shouldIgnoreWhiteListingIfFullAccess.
@Test
void shouldIgnoreWhiteListingIfFullAccess() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_allowlist, List.of("empty")));
Log log = mock(Log.class);
ProcedureCompiler procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, null, true).get(0);
// Then
RawIterator<AnyValue[], ProcedureException> result = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
assertEquals(result.next()[0], stringValue("Bonnie"));
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProceduresTest method shouldNotAllowRegisteringConflictingName.
@Test
void shouldNotAllowRegisteringConflictingName() throws Throwable {
// Given
procs.register(procedure);
ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.register(procedure));
assertThat(exception.getMessage()).isEqualTo("Unable to register procedure, because the name `org.myproc` is already in use.");
}
Aggregations