use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltRequestMessageReaderV43 method buildDecoders.
private static List<RequestMessageDecoder> buildDecoders(BoltConnection connection, BoltResponseMessageWriter responseMessageWriter, BookmarksParser bookmarksParser, LogService logService) {
BoltResponseHandler resultHandler = new ResultHandler(responseMessageWriter, connection, internalLog(logService));
BoltResponseHandler defaultHandler = newSimpleResponseHandler(responseMessageWriter, connection, logService);
return Arrays.asList(new HelloMessageDecoder(defaultHandler), new RunMessageDecoder(defaultHandler, bookmarksParser), new DiscardMessageDecoder(resultHandler), new PullMessageDecoder(resultHandler), new BeginMessageDecoder(defaultHandler, bookmarksParser), new CommitMessageDecoder(resultHandler), new RollbackMessageDecoder(resultHandler), new ResetMessageDecoder(connection, defaultHandler), new GoodbyeMessageDecoder(connection, defaultHandler), // New in 4.3
new RouteMessageDecoder(defaultHandler, bookmarksParser));
}
use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltRequestMessageReaderTest method shouldHandleErrorThatCausesFailureMessage.
@Test
void shouldHandleErrorThatCausesFailureMessage() throws Exception {
Unpacker unpacker = mock(Unpacker.class);
BoltIOException error = new BoltIOException(Status.General.UnknownError, "Hello");
when(unpacker.unpackStructHeader()).thenThrow(error);
BoltStateMachine stateMachine = mock(BoltStateMachine.class);
BoltConnection connection = new SynchronousBoltConnection(stateMachine);
BoltResponseHandler externalErrorResponseHandler = responseHandlerMock();
BoltRequestMessageReader reader = new TestBoltRequestMessageReader(connection, externalErrorResponseHandler, emptyList(), mock(ChannelProtector.class));
reader.read(unpacker);
verify(stateMachine).handleExternalFailure(Neo4jError.from(error), externalErrorResponseHandler);
}
use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltRequestMessageReaderTest method shouldDecodeKnownMessage.
@Test
void shouldDecodeKnownMessage() throws Exception {
Unpacker unpacker = mock(Unpacker.class);
when(unpacker.unpackStructSignature()).thenReturn('a');
RequestMessage message = mock(RequestMessage.class);
BoltResponseHandler responseHandler = responseHandlerMock();
RequestMessageDecoder decoder = new TestRequestMessageDecoder('a', responseHandler, message);
BoltStateMachine stateMachine = mock(BoltStateMachine.class);
BoltConnection connection = new SynchronousBoltConnection(stateMachine);
BoltRequestMessageReader reader = new TestBoltRequestMessageReader(connection, responseHandlerMock(), singletonList(decoder), mock(ChannelProtector.class));
reader.read(unpacker);
verify(stateMachine).process(message, responseHandler);
}
use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltRequestMessageReaderV4 method buildDecoders.
private static List<RequestMessageDecoder> buildDecoders(BoltConnection connection, BoltResponseMessageWriter responseMessageWriter, BookmarksParser bookmarksParser, LogService logService) {
BoltResponseHandler resultHandler = new ResultHandler(responseMessageWriter, connection, internalLog(logService));
BoltResponseHandler defaultHandler = newSimpleResponseHandler(responseMessageWriter, connection, logService);
return Arrays.asList(new HelloMessageDecoder(defaultHandler), // New
new RunMessageDecoder(defaultHandler, bookmarksParser), // New
new DiscardMessageDecoder(resultHandler), // New
new PullMessageDecoder(resultHandler), // New
new BeginMessageDecoder(defaultHandler, bookmarksParser), new CommitMessageDecoder(resultHandler), new RollbackMessageDecoder(resultHandler), new ResetMessageDecoder(connection, defaultHandler), new GoodbyeMessageDecoder(connection, defaultHandler));
}
use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldTerminateOnAuthExpiryDuringSTREAMINGDiscardAll.
@Test
void shouldTerminateOnAuthExpiryDuringSTREAMINGDiscardAll() throws Throwable {
// Given
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
doThrow(new AuthorizationExpiredException("Auth expired!")).when(responseHandler).onDiscardRecords(any(), eq(STREAM_LIMIT_UNLIMITED));
BoltStateMachine machine = init(newMachine());
// move to streaming state
machine.process(BoltV4Messages.run(), nullResponseHandler());
// We assume the only implementation of statement processor is TransactionStateMachine
txStateMachine(machine).ctx.statementOutcomes.put(StatementMetadata.ABSENT_QUERY_ID, new StatementOutcome(BoltResult.EMPTY));
// When & Then
try {
machine.process(BoltV4Messages.discardAll(), responseHandler);
fail("Exception expected");
} catch (BoltConnectionAuthFatality e) {
assertEquals("Auth expired!", e.getCause().getMessage());
}
}
Aggregations