Search in sources :

Example 6 with BoltProtocolVersion

use of org.neo4j.bolt.BoltProtocolVersion in project neo4j by neo4j.

the class BoltProtocolV42Test method shouldVersionReturnBoltV42.

@Test
void shouldVersionReturnBoltV42() {
    BoltProtocolV42 protocolV42 = createProtocolV42();
    assertThat(protocolV42.version()).isEqualTo(new BoltProtocolVersion(4, 2));
}
Also used : BoltProtocolVersion(org.neo4j.bolt.BoltProtocolVersion) Test(org.junit.jupiter.api.Test)

Example 7 with BoltProtocolVersion

use of org.neo4j.bolt.BoltProtocolVersion in project neo4j by neo4j.

the class BoltProtocolV43Test method shouldVersionReturnBoltV43.

@Test
void shouldVersionReturnBoltV43() {
    BoltProtocolV43 protocolV43 = createProtocolV43();
    assertThat(protocolV43.version()).isEqualTo(new BoltProtocolVersion(4, 3));
}
Also used : BoltProtocolVersion(org.neo4j.bolt.BoltProtocolVersion) Test(org.junit.jupiter.api.Test)

Example 8 with BoltProtocolVersion

use of org.neo4j.bolt.BoltProtocolVersion in project neo4j by neo4j.

the class DefaultBoltProtocolFactoryTest method shouldCreateBoltProtocol.

@ParameterizedTest(name = "V{0}.{1}")
@CsvSource({ "3, 0", "4, 0", "4, 1", "4, 2", "4, 3" })
void shouldCreateBoltProtocol(int majorVersion, int minorVersion) throws Throwable {
    EmbeddedChannel channel = new EmbeddedChannel();
    BoltChannel boltChannel = newTestBoltChannel(channel);
    BoltProtocolVersion boltProtocolVersion = new BoltProtocolVersion(majorVersion, minorVersion);
    BoltStateMachineFactory stateMachineFactory = mock(BoltStateMachineFactory.class);
    BoltStateMachine stateMachine = mock(BoltStateMachine.class);
    var channelProtector = mock(ChannelProtector.class);
    var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
    when(stateMachineFactory.newStateMachine(boltProtocolVersion, boltChannel, MapValue.EMPTY, memoryTracker)).thenReturn(stateMachine);
    BoltConnectionFactory connectionFactory = mock(BoltConnectionFactory.class);
    BoltConnection connection = mock(BoltConnection.class);
    when(connectionFactory.newConnection(eq(boltChannel), eq(stateMachine), any())).thenReturn(connection);
    BoltProtocolFactory factory = new DefaultBoltProtocolFactory(connectionFactory, stateMachineFactory, Config.defaults(), NullLogService.getInstance(), new TestDatabaseIdRepository(), CustomBookmarkFormatParser.DEFAULT, mock(TransportThrottleGroup.class), Clocks.fakeClock(), Duration.ZERO);
    BoltProtocol protocol = factory.create(boltProtocolVersion, boltChannel, channelProtector, memoryTracker);
    protocol.install();
    // handler with correct version is created
    assertEquals(boltProtocolVersion, protocol.version());
    // it uses the expected worker
    verify(connectionFactory).newConnection(eq(boltChannel), any(BoltStateMachine.class), any(BoltResponseMessageWriter.class));
    verify(memoryTracker, times(5)).allocateHeap(anyLong());
    // and halts this same worker when closed
    verify(connection, never()).stop();
    channel.close();
    verify(connection).stop();
    channel.finishAndReleaseAll();
}
Also used : BoltResponseMessageWriter(org.neo4j.bolt.messaging.BoltResponseMessageWriter) BoltConnectionFactory(org.neo4j.bolt.runtime.BoltConnectionFactory) BoltStateMachineFactory(org.neo4j.bolt.runtime.statemachine.BoltStateMachineFactory) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) TestDatabaseIdRepository(org.neo4j.kernel.database.TestDatabaseIdRepository) BoltProtocol(org.neo4j.bolt.BoltProtocol) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) BoltProtocolVersion(org.neo4j.bolt.BoltProtocolVersion) BoltChannel(org.neo4j.bolt.BoltChannel) BoltTestUtil.newTestBoltChannel(org.neo4j.bolt.testing.BoltTestUtil.newTestBoltChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with BoltProtocolVersion

use of org.neo4j.bolt.BoltProtocolVersion in project neo4j by neo4j.

the class BoltProtocolV41Test method shouldVersionReturnBoltV41.

@Test
void shouldVersionReturnBoltV41() {
    BoltProtocolV41 protocolV41 = createProtocolV41();
    assertThat(protocolV41.version()).isEqualTo(new BoltProtocolVersion(4, 1));
}
Also used : BoltProtocolVersion(org.neo4j.bolt.BoltProtocolVersion) Test(org.junit.jupiter.api.Test)

Example 10 with BoltProtocolVersion

use of org.neo4j.bolt.BoltProtocolVersion in project neo4j by neo4j.

the class BoltProtocolV3Test method shouldVersionReturnBoltV3.

@Test
void shouldVersionReturnBoltV3() throws Throwable {
    BoltProtocolV3 protocolV3 = createProtocolV3();
    assertThat(protocolV3.version()).isEqualTo(new BoltProtocolVersion(3, 0));
}
Also used : BoltProtocolVersion(org.neo4j.bolt.BoltProtocolVersion) Test(org.junit.jupiter.api.Test)

Aggregations

BoltProtocolVersion (org.neo4j.bolt.BoltProtocolVersion)17 Test (org.junit.jupiter.api.Test)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)6 BoltProtocol (org.neo4j.bolt.BoltProtocol)5 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 ByteBuf (io.netty.buffer.ByteBuf)2 BoltChannel (org.neo4j.bolt.BoltChannel)2 BoltConnectionFactory (org.neo4j.bolt.runtime.BoltConnectionFactory)2 BoltStateMachineFactory (org.neo4j.bolt.runtime.statemachine.BoltStateMachineFactory)2 BoltTestUtil.newTestBoltChannel (org.neo4j.bolt.testing.BoltTestUtil.newTestBoltChannel)2 BoltProtocolFactory (org.neo4j.bolt.transport.BoltProtocolFactory)2 TestDatabaseIdRepository (org.neo4j.kernel.database.TestDatabaseIdRepository)2 ArrayList (java.util.ArrayList)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)1 BoltConnection (org.neo4j.bolt.runtime.BoltConnection)1 ChannelProtector (org.neo4j.bolt.transport.pipeline.ChannelProtector)1