Search in sources :

Example 31 with BoltConnection

use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.

the class ExecutorBoltSchedulerTest method successfulJobsShouldTriggerSchedulingOfPendingJobs.

@Test
void successfulJobsShouldTriggerSchedulingOfPendingJobs() throws Throwable {
    AtomicInteger counter = new AtomicInteger();
    String id = UUID.randomUUID().toString();
    BoltConnection connection = newConnection(id);
    when(connection.processNextBatch()).thenAnswer(inv -> counter.incrementAndGet() > 0);
    when(connection.hasPendingJobs()).thenReturn(true).thenReturn(false);
    boltScheduler.init();
    boltScheduler.start();
    boltScheduler.created(connection);
    boltScheduler.enqueued(connection, Jobs.noop());
    Predicates.await(() -> counter.get() > 1, 1, MINUTES);
    verify(connection, times(2)).processNextBatch();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) Test(org.junit.jupiter.api.Test)

Aggregations

BoltConnection (org.neo4j.bolt.runtime.BoltConnection)31 Test (org.junit.jupiter.api.Test)24 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 InetSocketAddress (java.net.InetSocketAddress)3 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)3 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)3 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)3 ChannelProtector (org.neo4j.bolt.transport.pipeline.ChannelProtector)3 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)3 Bootstrap (io.netty.bootstrap.Bootstrap)2 Channel (io.netty.channel.Channel)2 ChannelFuture (io.netty.channel.ChannelFuture)2 ChannelInboundHandler (io.netty.channel.ChannelInboundHandler)2 SocketChannel (io.netty.channel.socket.SocketChannel)2 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)2 ServerSocket (java.net.ServerSocket)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2