Search in sources :

Example 6 with HostnamePort

use of org.neo4j.internal.helpers.HostnamePort in project neo4j by neo4j.

the class HttpsAccessIT method shouldInstallConnector.

private void shouldInstallConnector(String scheme) {
    var uri = testWebContainer.getBaseUri();
    assertEquals(scheme, uri.getScheme());
    HostnamePort expectedHostPort = PortUtils.getConnectorAddress(testWebContainer.getDefaultDatabase(), scheme);
    assertEquals(expectedHostPort.getHost(), uri.getHost());
    assertEquals(expectedHostPort.getPort(), uri.getPort());
}
Also used : HostnamePort(org.neo4j.internal.helpers.HostnamePort)

Example 7 with HostnamePort

use of org.neo4j.internal.helpers.HostnamePort in project neo4j by neo4j.

the class MultipleBoltServerPortsStressTest method splitTrafficBetweenPorts.

@Test
void splitTrafficBetweenPorts() throws Exception {
    SocketConnection externalConnection = new SocketConnection();
    SocketConnection internalConnection = new SocketConnection();
    try {
        HostnamePort externalAddress = server.lookupConnector(BoltConnector.NAME);
        HostnamePort internalAddress = server.lookupConnector(BoltConnector.INTERNAL_NAME);
        executeStressTest(Executors.newFixedThreadPool(NUMBER_OF_THREADS), externalAddress, internalAddress);
    } finally {
        externalConnection.disconnect();
        internalConnection.disconnect();
    }
}
Also used : SocketConnection(org.neo4j.bolt.testing.client.SocketConnection) HostnamePort(org.neo4j.internal.helpers.HostnamePort) Test(org.junit.jupiter.api.Test)

Example 8 with HostnamePort

use of org.neo4j.internal.helpers.HostnamePort in project neo4j by neo4j.

the class SocketConnectionTest method shouldOnlyReadOnceIfAllBytesAreRead.

@Test
void shouldOnlyReadOnceIfAllBytesAreRead() throws Exception {
    // GIVEN
    Socket socket = mock(Socket.class);
    InputStream stream = mock(InputStream.class);
    when(socket.getInputStream()).thenReturn(stream);
    when(stream.read(any(byte[].class), anyInt(), anyInt())).thenReturn(4);
    SocketConnection connection = new SocketConnection(socket);
    connection.connect(new HostnamePort("my.domain", 1234));
    // WHEN
    connection.recv(4);
    // THEN
    verify(stream).read(any(byte[].class), anyInt(), anyInt());
}
Also used : InputStream(java.io.InputStream) HostnamePort(org.neo4j.internal.helpers.HostnamePort) Socket(java.net.Socket) Test(org.junit.jupiter.api.Test)

Example 9 with HostnamePort

use of org.neo4j.internal.helpers.HostnamePort in project neo4j by neo4j.

the class SocketConnectionTest method shouldThrowIfNotEnoughBytesAreRead.

@Test
void shouldThrowIfNotEnoughBytesAreRead() throws Exception {
    // GIVEN
    Socket socket = mock(Socket.class);
    InputStream stream = mock(InputStream.class);
    when(socket.getInputStream()).thenReturn(stream);
    when(stream.read(any(byte[].class), anyInt(), anyInt())).thenReturn(4).thenReturn(-1);
    SocketConnection connection = new SocketConnection(socket);
    connection.connect(new HostnamePort("my.domain", 1234));
    // WHEN
    assertThrows(IOException.class, () -> connection.recv(10));
}
Also used : InputStream(java.io.InputStream) HostnamePort(org.neo4j.internal.helpers.HostnamePort) Socket(java.net.Socket) Test(org.junit.jupiter.api.Test)

Example 10 with HostnamePort

use of org.neo4j.internal.helpers.HostnamePort in project neo4j by neo4j.

the class SocketConnectionTest method shouldOnlyReadUntilAllBytesAreRead.

@Test
void shouldOnlyReadUntilAllBytesAreRead() throws Exception {
    // GIVEN
    Socket socket = mock(Socket.class);
    InputStream stream = mock(InputStream.class);
    when(socket.getInputStream()).thenReturn(stream);
    when(stream.read(any(byte[].class), anyInt(), anyInt())).thenReturn(4).thenReturn(4).thenReturn(2).thenReturn(-1);
    SocketConnection connection = new SocketConnection(socket);
    connection.connect(new HostnamePort("my.domain", 1234));
    // WHEN
    connection.recv(10);
    // THEN
    verify(stream, times(3)).read(any(byte[].class), anyInt(), anyInt());
}
Also used : InputStream(java.io.InputStream) HostnamePort(org.neo4j.internal.helpers.HostnamePort) Socket(java.net.Socket) Test(org.junit.jupiter.api.Test)

Aggregations

HostnamePort (org.neo4j.internal.helpers.HostnamePort)18 Test (org.junit.jupiter.api.Test)7 SocketAddress (org.neo4j.configuration.helpers.SocketAddress)5 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)5 SocketConnection (org.neo4j.bolt.testing.client.SocketConnection)4 InputStream (java.io.InputStream)3 Socket (java.net.Socket)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MapValueBuilder (org.neo4j.values.virtual.MapValueBuilder)3 URI (java.net.URI)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 DynamicTest (org.junit.jupiter.api.DynamicTest)1 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)1 DependencyResolver (org.neo4j.common.DependencyResolver)1