Search in sources :

Example 6 with BoltRequestMessageReader

use of org.neo4j.bolt.messaging.BoltRequestMessageReader in project neo4j by neo4j.

the class BoltRequestMessageReaderV3Test method testMessageDecoding.

private static void testMessageDecoding(RequestMessage message) throws Exception {
    Neo4jPack neo4jPack = newNeo4jPack();
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    BoltRequestMessageReader reader = requestMessageReader(stateMachine);
    PackedInputArray input = new PackedInputArray(encode(neo4jPack, message));
    Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
    reader.read(unpacker);
    verify(stateMachine).process(eq(message), any());
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltRequestMessageReader(org.neo4j.bolt.messaging.BoltRequestMessageReader) PackedInputArray(org.neo4j.bolt.packstream.PackedInputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BoltProtocolV3ComponentFactory.newNeo4jPack(org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack)

Example 7 with BoltRequestMessageReader

use of org.neo4j.bolt.messaging.BoltRequestMessageReader in project neo4j by neo4j.

the class MessageDecoderTest method shouldLogContentOfTheMessageOnIOError.

@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldLogContentOfTheMessageOnIOError(Neo4jPack packerUnderTest) throws Exception {
    this.packerUnderTest = packerUnderTest;
    BoltConnection connection = mock(BoltConnection.class);
    BoltResponseMessageWriter responseMessageHandler = mock(BoltResponseMessageWriter.class);
    BoltRequestMessageReader requestMessageReader = new BoltRequestMessageReaderV3(connection, responseMessageHandler, mock(ChannelProtector.class), NullLogService.getInstance());
    LogService logService = mock(LogService.class);
    Log log = mock(Log.class);
    when(logService.getInternalLog(MessageDecoder.class)).thenReturn(log);
    channel = new EmbeddedChannel(new MessageDecoder(packerUnderTest::newUnpacker, requestMessageReader, logService));
    byte invalidMessageSignature = Byte.MAX_VALUE;
    byte[] messageBytes = packMessageWithSignature(invalidMessageSignature);
    assertThrows(BoltIOException.class, () -> channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)));
    assertMessageHexDumpLogged(log, messageBytes);
}
Also used : BoltResponseMessageWriter(org.neo4j.bolt.messaging.BoltResponseMessageWriter) ChannelProtector(org.neo4j.bolt.transport.pipeline.ChannelProtector) MessageDecoder(org.neo4j.bolt.transport.pipeline.MessageDecoder) SynchronousBoltConnection(org.neo4j.bolt.runtime.SynchronousBoltConnection) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) BoltRequestMessageReader(org.neo4j.bolt.messaging.BoltRequestMessageReader) Log(org.neo4j.logging.Log) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) BoltRequestMessageReaderV3(org.neo4j.bolt.v3.messaging.BoltRequestMessageReaderV3) NullLogService(org.neo4j.logging.internal.NullLogService) LogService(org.neo4j.logging.internal.LogService) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with BoltRequestMessageReader

use of org.neo4j.bolt.messaging.BoltRequestMessageReader in project neo4j by neo4j.

the class BoltRequestMessageReaderV4Test method verifyBoltV3MessageIsReadAsBoltV4Message.

private static void verifyBoltV3MessageIsReadAsBoltV4Message(TransactionInitiatingMessage messageV3, TransactionInitiatingMessage messageV4) throws Exception {
    Neo4jPack neo4jPack = newNeo4jPack();
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    BoltRequestMessageReader reader = requestMessageReader(stateMachine);
    PackedInputArray input = new PackedInputArray(encode(neo4jPack, messageV3));
    Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
    reader.read(unpacker);
    verify(stateMachine).process(eq(messageV4), any());
    assertThat(messageV3.meta()).isEqualTo(messageV4.meta());
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltRequestMessageReader(org.neo4j.bolt.messaging.BoltRequestMessageReader) PackedInputArray(org.neo4j.bolt.packstream.PackedInputArray) BoltProtocolV4ComponentFactory.newNeo4jPack(org.neo4j.bolt.v4.BoltProtocolV4ComponentFactory.newNeo4jPack) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Example 9 with BoltRequestMessageReader

use of org.neo4j.bolt.messaging.BoltRequestMessageReader in project neo4j by neo4j.

the class BoltRequestMessageReaderV41Test method testMessageDecoding.

private static void testMessageDecoding(RequestMessage message) throws Exception {
    Neo4jPack neo4jPack = newNeo4jPack();
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    BoltRequestMessageReader reader = requestMessageReader(stateMachine);
    PackedInputArray input = new PackedInputArray(encode(neo4jPack, message));
    Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
    reader.read(unpacker);
    verify(stateMachine).process(eq(message), any());
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltRequestMessageReader(org.neo4j.bolt.messaging.BoltRequestMessageReader) PackedInputArray(org.neo4j.bolt.packstream.PackedInputArray) BoltProtocolV41ComponentFactory.newNeo4jPack(org.neo4j.bolt.v41.BoltProtocolV41ComponentFactory.newNeo4jPack) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Example 10 with BoltRequestMessageReader

use of org.neo4j.bolt.messaging.BoltRequestMessageReader in project neo4j by neo4j.

the class BoltRequestMessageReaderV43Test method testMessageDecoding.

private static void testMessageDecoding(RequestMessage message) throws Exception {
    Neo4jPack neo4jPack = newNeo4jPack();
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    BoltRequestMessageReader reader = requestMessageReader(stateMachine);
    PackedInputArray input = new PackedInputArray(encode(neo4jPack, message));
    Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
    reader.read(unpacker);
    verify(stateMachine).process(eq(message), any());
}
Also used : BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltRequestMessageReader(org.neo4j.bolt.messaging.BoltRequestMessageReader) PackedInputArray(org.neo4j.bolt.packstream.PackedInputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BoltProtocolV43ComponentFactory.newNeo4jPack(org.neo4j.bolt.v43.BoltProtocolV43ComponentFactory.newNeo4jPack)

Aggregations

BoltRequestMessageReader (org.neo4j.bolt.messaging.BoltRequestMessageReader)10 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)8 PackedInputArray (org.neo4j.bolt.packstream.PackedInputArray)8 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)8 NullLogService (org.neo4j.logging.internal.NullLogService)3 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)2 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)2 ChannelProtector (org.neo4j.bolt.transport.pipeline.ChannelProtector)2 MessageDecoder (org.neo4j.bolt.transport.pipeline.MessageDecoder)2 BoltProtocolV3ComponentFactory.newNeo4jPack (org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack)2 BoltProtocolV4ComponentFactory.newNeo4jPack (org.neo4j.bolt.v4.BoltProtocolV4ComponentFactory.newNeo4jPack)2 BoltProtocolV41ComponentFactory.newNeo4jPack (org.neo4j.bolt.v41.BoltProtocolV41ComponentFactory.newNeo4jPack)2 IOException (java.io.IOException)1 System.lineSeparator (java.lang.System.lineSeparator)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1