use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine 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());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class MessageDecoderTest method unpack.
private void unpack(byte[] input) {
BoltStateMachine stateMachine = mock(BoltStateMachine.class);
SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine);
channel = new EmbeddedChannel(newDecoder(connection));
channel.writeInbound(Unpooled.wrappedBuffer(input));
channel.finishAndReleaseAll();
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class MessageDecoderTest method shouldDispatchRequestMessage.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldDispatchRequestMessage(Neo4jPack packerUnderTest) throws Exception {
this.packerUnderTest = packerUnderTest;
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());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class MessageDecoderTest method testUnpackableStructParametersWithKnownType.
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());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method shouldCreateBoltStateMachinesV42.
@Test
void shouldCreateBoltStateMachinesV42() {
BoltStateMachineFactoryImpl factory = newBoltFactory();
var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
BoltStateMachine boltStateMachine = factory.newStateMachine(new BoltProtocolVersion(4, 2), CHANNEL, MapValue.EMPTY, memoryTracker);
assertNotNull(boltStateMachine);
assertThat(boltStateMachine).isInstanceOf(BoltStateMachineV42.class);
verify(memoryTracker).getScopedMemoryTracker();
verify(memoryTracker, times(3)).allocateHeap(anyLong());
verifyNoMoreInteractions(memoryTracker);
}
Aggregations