Search in sources :

Example 1 with SocketConnection

use of org.neo4j.bolt.v1.transport.socket.client.SocketConnection in project neo4j by neo4j.

the class BoltConfigIT method shouldSupportMultipleConnectors.

@Test
public void shouldSupportMultipleConnectors() throws Throwable {
    // Given
    // When
    // Then
    HostnamePort address0 = new HostnamePort("localhost:7888");
    assertConnectionAccepted(address0, new WebSocketConnection());
    assertConnectionAccepted(address0, new SecureWebSocketConnection());
    assertConnectionAccepted(address0, new SocketConnection());
    assertConnectionAccepted(address0, new SecureSocketConnection());
    HostnamePort address1 = new HostnamePort("localhost:7687");
    assertConnectionRejected(address1, new WebSocketConnection());
    assertConnectionAccepted(address1, new SecureWebSocketConnection());
    assertConnectionRejected(address1, new SocketConnection());
    assertConnectionAccepted(address1, new SecureSocketConnection());
}
Also used : SecureSocketConnection(org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection) SecureWebSocketConnection(org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection) SecureWebSocketConnection(org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection) WebSocketConnection(org.neo4j.bolt.v1.transport.socket.client.WebSocketConnection) SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) SecureWebSocketConnection(org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection) SecureSocketConnection(org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection) WebSocketConnection(org.neo4j.bolt.v1.transport.socket.client.WebSocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) Test(org.junit.Test)

Example 2 with SocketConnection

use of org.neo4j.bolt.v1.transport.socket.client.SocketConnection in project neo4j by neo4j.

the class ProcedureInteractionTestBase method startBoltSession.

@SuppressWarnings("unchecked")
TransportConnection startBoltSession(String username, String password) throws Exception {
    TransportConnection connection = new SocketConnection();
    HostnamePort address = new HostnamePort("localhost:7687");
    Map<String, Object> authToken = map("principal", username, "credentials", password, "scheme", "basic");
    connection.connect(address).send(TransportTestUtil.acceptedVersions(1, 0, 0, 0)).send(TransportTestUtil.chunk(init("TestClient/1.1", authToken)));
    assertThat(connection, eventuallyReceives(new byte[] { 0, 0, 0, 1 }));
    assertThat(connection, eventuallyReceives(msgSuccess()));
    return connection;
}
Also used : TransportConnection(org.neo4j.bolt.v1.transport.socket.client.TransportConnection) SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 3 with SocketConnection

use of org.neo4j.bolt.v1.transport.socket.client.SocketConnection in project neo4j by neo4j.

the class BoltMetricsIT method shouldMonitorBolt.

@Test
public void shouldMonitorBolt() throws Throwable {
    // Given
    File metricsFolder = tmpDir.newFolder("metrics");
    db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(new BoltConnector("bolt").type, "BOLT").setConfig(new BoltConnector("bolt").enabled, "true").setConfig(GraphDatabaseSettings.auth_enabled, "false").setConfig(MetricsSettings.boltMessagesEnabled, "true").setConfig(MetricsSettings.csvEnabled, "true").setConfig(MetricsSettings.csvInterval, "100ms").setConfig(MetricsSettings.csvPath, metricsFolder.getAbsolutePath()).newGraphDatabase();
    // When
    conn = new SocketConnection().connect(new HostnamePort("localhost", 7687)).send(acceptedVersions(1, 0, 0, 0)).send(chunk(InitMessage.init("TestClient", map("scheme", "basic", "principal", "neo4j", "credentials", "neo4j"))));
    // Then
    assertEventually("session shows up as started", () -> readLongValue(metricsCsv(metricsFolder, SESSIONS_STARTED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as received", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_RECIEVED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as started", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_STARTED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as done", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_DONE)), equalTo(1L), 5, SECONDS);
    assertEventually("queue time shows up", () -> readLongValue(metricsCsv(metricsFolder, TOTAL_QUEUE_TIME)), greaterThanOrEqualTo(0L), 5, SECONDS);
    assertEventually("processing time shows up", () -> readLongValue(metricsCsv(metricsFolder, TOTAL_PROCESSING_TIME)), greaterThanOrEqualTo(0L), 5, SECONDS);
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 4 with SocketConnection

use of org.neo4j.bolt.v1.transport.socket.client.SocketConnection in project neo4j by neo4j.

the class InProcessBuilderTest method shouldOpenBoltPort.

@Test
public void shouldOpenBoltPort() throws Throwable {
    // given
    try (ServerControls controls = newInProcessBuilder().newServer()) {
        URI uri = controls.boltURI();
        // when
        new SocketConnection().connect(new HostnamePort(uri.getHost(), uri.getPort()));
    // then no exception
    }
}
Also used : SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) URI(java.net.URI) Test(org.junit.Test)

Aggregations

SocketConnection (org.neo4j.bolt.v1.transport.socket.client.SocketConnection)4 HostnamePort (org.neo4j.helpers.HostnamePort)4 Test (org.junit.Test)3 File (java.io.File)1 URI (java.net.URI)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 SecureSocketConnection (org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection)1 SecureWebSocketConnection (org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection)1 TransportConnection (org.neo4j.bolt.v1.transport.socket.client.TransportConnection)1 WebSocketConnection (org.neo4j.bolt.v1.transport.socket.client.WebSocketConnection)1 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)1 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)1