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());
}
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();
}
}
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());
}
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));
}
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());
}
Aggregations