Search in sources :

Example 46 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class RoutingResultFormat method parseRows.

private static Map<Role, List<SocketAddress>> parseRows(ListValue rows) {
    Map<Role, List<SocketAddress>> endpoints = new HashMap<>();
    for (AnyValue single : rows) {
        MapValue row = (MapValue) single;
        Role role = Role.valueOf(((TextValue) row.get("role")).stringValue());
        List<SocketAddress> addresses = parseEndpoints((ListValue) row.get("addresses"));
        endpoints.put(role, addresses);
    }
    Arrays.stream(Role.values()).forEach(r -> endpoints.putIfAbsent(r, Collections.emptyList()));
    return endpoints;
}
Also used : HashMap(java.util.HashMap) AnyValue(org.neo4j.values.AnyValue) ArrayList(java.util.ArrayList) List(java.util.List) MapValue(org.neo4j.values.virtual.MapValue) SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Example 47 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldDeriveListenAddressFromDefaultListenAddressAndSpecifiedPorts.

@Test
void shouldDeriveListenAddressFromDefaultListenAddressAndSpecifiedPorts() {
    // given
    Config config = Config.newBuilder().set(GraphDatabaseSettings.default_listen_address, new SocketAddress("0.0.0.0")).set(HttpConnector.listen_address, new SocketAddress(8000)).set(HttpsConnector.listen_address, new SocketAddress(9000)).set(BoltConnector.listen_address, new SocketAddress(10000)).build();
    // then
    assertEquals(new SocketAddress("0.0.0.0", 9000), config.get(HttpsConnector.listen_address));
    assertEquals(new SocketAddress("0.0.0.0", 8000), config.get(HttpConnector.listen_address));
    assertEquals(new SocketAddress("0.0.0.0", 10000), config.get(BoltConnector.listen_address));
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.jupiter.api.Test)

Example 48 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldBeAbleToOverrideBoltListenAddressesWithJustOneParameter.

@Test
void shouldBeAbleToOverrideBoltListenAddressesWithJustOneParameter() {
    // given
    Config config = Config.newBuilder().set(BoltConnector.enabled, true).set(BoltConnector.listen_address, new SocketAddress(8000)).build();
    // then
    assertEquals(new SocketAddress("localhost", 8000), config.get(BoltConnector.listen_address));
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.jupiter.api.Test)

Example 49 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldDeriveListenAddressFromDefaultListenAddress.

@Test
void shouldDeriveListenAddressFromDefaultListenAddress() {
    // given
    Config config = Config.newBuilder().set(GraphDatabaseSettings.default_listen_address, new SocketAddress("0.0.0.0")).setDefaults(GraphDatabaseSettings.SERVER_DEFAULTS).build();
    // then
    assertEquals("0.0.0.0", config.get(HttpConnector.listen_address).getHostname());
    assertEquals("0.0.0.0", config.get(HttpsConnector.listen_address).getHostname());
    assertEquals("0.0.0.0", config.get(BoltConnector.listen_address).getHostname());
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.jupiter.api.Test)

Example 50 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldEnableBoltByDefault.

@Test
void shouldEnableBoltByDefault() {
    // given
    Config config = Config.newBuilder().setDefaults(GraphDatabaseSettings.SERVER_DEFAULTS).build();
    // when
    SocketAddress listenSocketAddress = config.get(BoltConnector.listen_address);
    // then
    assertEquals(new SocketAddress("localhost", 7687), listenSocketAddress);
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.jupiter.api.Test)

Aggregations

SocketAddress (org.neo4j.configuration.helpers.SocketAddress)54 Test (org.junit.jupiter.api.Test)27 InetSocketAddress (java.net.InetSocketAddress)12 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)11 Test (org.junit.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 HostnamePort (org.neo4j.internal.helpers.HostnamePort)5 MapValueBuilder (org.neo4j.values.virtual.MapValueBuilder)5 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 EnterpriseDatabaseManagementServiceBuilder (com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder)2 IOException (java.io.IOException)2 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 DynamicTest (org.junit.jupiter.api.DynamicTest)2 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)2 Config (org.neo4j.configuration.Config)2 ConnectorPortRegister (org.neo4j.configuration.connectors.ConnectorPortRegister)2 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)2