Search in sources :

Example 1 with BoltMessageRouter

use of org.neo4j.bolt.v1.messaging.BoltMessageRouter in project neo4j by neo4j.

the class ResetFuzzTest method shouldAlwaysReturnToReadyAfterReset.

@Test
public void shouldAlwaysReturnToReadyAfterReset() throws Throwable {
    // given
    life.start();
    BoltWorker boltWorker = sessions.newWorker(CONNECTION_DESCRIPTOR);
    boltWorker.enqueue(session -> session.init("ResetFuzzTest/0.0", map(), nullResponseHandler()));
    BoltMessageRouter router = new BoltMessageRouter(NullLog.getInstance(), boltWorker, new BoltResponseMessageHandler<IOException>() {

        @Override
        public void onRecord(Record item) throws IOException {
        }

        @Override
        public void onIgnored() throws IOException {
        }

        @Override
        public void onFailure(Status status, String message) throws IOException {
        }

        @Override
        public void onSuccess(Map metadata) throws IOException {
        }
    }, () -> {
    });
    // Test random combinations of messages within a small budget of testing time.
    long deadline = System.currentTimeMillis() + 2 * 1000;
    // when
    while (System.currentTimeMillis() < deadline) {
        dispatchRandomSequenceOfMessages(router);
        assertWorkerWorks(boltWorker);
    }
}
Also used : Status(org.neo4j.kernel.api.exceptions.Status) Record(org.neo4j.bolt.v1.runtime.spi.Record) BoltMessageRouter(org.neo4j.bolt.v1.messaging.BoltMessageRouter) IOException(java.io.IOException) Map(java.util.Map) Test(org.junit.Test)

Example 2 with BoltMessageRouter

use of org.neo4j.bolt.v1.messaging.BoltMessageRouter in project neo4j by neo4j.

the class ResetFuzzTest method dispatchRandomSequenceOfMessages.

private void dispatchRandomSequenceOfMessages(BoltMessageRouter messageHandler) {
    List<RequestMessage> sequence = sequences.get(rand.nextInt(sequences.size()));
    for (RequestMessage message : sequence) {
        sent.add(message);
        message.dispatch(messageHandler);
    }
}
Also used : RequestMessage(org.neo4j.bolt.v1.messaging.message.RequestMessage)

Aggregations

IOException (java.io.IOException)1 Map (java.util.Map)1 Test (org.junit.Test)1 BoltMessageRouter (org.neo4j.bolt.v1.messaging.BoltMessageRouter)1 RequestMessage (org.neo4j.bolt.v1.messaging.message.RequestMessage)1 Record (org.neo4j.bolt.v1.runtime.spi.Record)1 Status (org.neo4j.kernel.api.exceptions.Status)1