### Question:
MessageProcessingHandler implements BoltResponseHandler { @Override public void onFinish() { try { if ( ignored ) { messageWriter.write( IGNORED_MESSAGE ); } else if ( error != null ) { publishError( messageWriter, error ); } else { messageWriter.write( new SuccessMessage( getMetadata() ) ); } } catch ( Throwable e ) { connection.stop(); log.error( "Failed to write response to driver", e ); } finally { clearState(); } } MessageProcessingHandler( BoltResponseMessageWriter messageWriter, BoltConnection connection, Log logger ); @Override void onRecords( BoltResult result, boolean pull ); @Override void onMetadata( String key, AnyValue value ); @Override void markIgnored(); @Override void markFailed( Neo4jError error ); @Override void onFinish();  }### Answer:
@Test public void shouldCallHaltOnUnexpectedFailures() throws Exception { BoltResponseMessageWriter msgWriter = newResponseHandlerMock(); doThrow( new RuntimeException( "Something went horribly wrong" ) ).when( msgWriter ).write( any( SuccessMessage.class ) ); BoltConnection connection = mock( BoltConnection.class ); MessageProcessingHandler handler = new MessageProcessingHandler( msgWriter, connection, mock( Log.class ) ); handler.onFinish(); verify( connection ).stop(); }