private void cleanup() { if (decoder != null) { // Clean-up the previous decoder if not cleaned up correctly. decoder.finishAndReleaseAll(); decoder = null; } }
@After public void cleanup() { if ( channel != null ) { channel.finishAndReleaseAll(); } }
@Override public void stop() { channel.finishAndReleaseAll(); machine.close(); } }
@After public void cleanup() { channel.finishAndReleaseAll(); }
@After public void cleanup() { channel.finishAndReleaseAll(); }
@After public void cleanup() { channel.finishAndReleaseAll(); }
@After public void cleanup() { if ( channel != null ) { channel.finishAndReleaseAll(); } }
@After public void cleanup() { if ( channel != null ) { channel.finishAndReleaseAll(); } }
@After public void cleanup() { channel.finishAndReleaseAll(); }
@After public void cleanup() { channel.finishAndReleaseAll(); }
@After public void tearDown() { out.close(); channel.finishAndReleaseAll(); }
private void unpack( byte[] input ) throws IOException { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( input ) ); channel.finishAndReleaseAll(); }
@Test public void shouldDispatchReset() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, ResetMessage.INSTANCE ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( eq( ResetMessage.INSTANCE ), any() ); }
@Test public void shouldDispatchAckFailure() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, AckFailureMessage.INSTANCE ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( eq( AckFailureMessage.INSTANCE ), any() ); }
@Test public void shouldDispatchDiscardAll() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, DiscardAllMessage.INSTANCE ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( eq( DiscardAllMessage.INSTANCE ), any() ); }
@Test public void shouldDispatchPullAll() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, PullAllMessage.INSTANCE ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( eq( PullAllMessage.INSTANCE ), any() ); }
private void testUnpackableStructParametersWithKnownType( Neo4jPack packerForSerialization, AnyValue parameterValue, String expectedMessage ) throws Exception { String statement = "RETURN $x"; MapValue parameters = VirtualValues.map( new String[]{"x"}, new AnyValue[]{parameterValue } ); BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerForSerialization, new RunMessage( statement, parameters ) ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).handleExternalFailure( eq( Neo4jError.from( Status.Statement.TypeError, expectedMessage ) ), any() ); }
@Test public void shouldCallExternalErrorOnInitWithNullKeys() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); String userAgent = "Test/User Agent 1.0"; Map<String,Object> authToken = MapUtil.map( "scheme", "basic", null, "user", "credentials", "password" ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, new InitMessage( userAgent, authToken ) ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).handleExternalFailure( eq( Neo4jError.from( Status.Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string." ) ), any() ); }
@Test public void shouldDispatchRun() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); String statement = "RETURN 1"; MapValue parameters = ValueUtils.asMapValue( MapUtil.map( "param1", 1, "param2", "2", "param3", true, "param4", 5.0 ) ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, new RunMessage( statement, parameters ) ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( eq( new RunMessage( statement, parameters ) ), any() ); }
@Test public void shouldDispatchInit() throws Exception { BoltStateMachine stateMachine = mock( BoltStateMachine.class ); SynchronousBoltConnection connection = new SynchronousBoltConnection( stateMachine ); channel = new EmbeddedChannel( newDecoder( connection ) ); String userAgent = "Test/User Agent 1.0"; Map<String, Object> authToken = MapUtil.map( "scheme", "basic", "principal", "user", "credentials", "password" ); channel.writeInbound( Unpooled.wrappedBuffer( serialize( packerUnderTest, new InitMessage( userAgent, authToken ) ) ) ); channel.finishAndReleaseAll(); verify( stateMachine ).process( refEq( new InitMessage( userAgent, authToken ), "authToken" ), any() ); }