Search in sources :

Example 31 with SocketAddress

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

the class InProcessServerBuilderIT method testStartupWithConnectors.

private void testStartupWithConnectors(boolean httpEnabled, boolean httpsEnabled, boolean boltEnabled) {
    var certificates = directory.directory("certificates");
    Neo4jBuilder serverBuilder = Neo4jBuilders.newInProcessBuilder(directory.homePath()).withConfig(HttpConnector.enabled, httpEnabled).withConfig(HttpConnector.listen_address, new SocketAddress(0)).withConfig(HttpsConnector.enabled, httpsEnabled).withConfig(HttpsConnector.listen_address, new SocketAddress(0)).withConfig(BoltConnector.enabled, boltEnabled).withConfig(BoltConnector.listen_address, new SocketAddress(0));
    if (httpsEnabled) {
        SelfSignedCertificateFactory.create(certificates);
        serverBuilder.withConfig(SslPolicyConfig.forScope(HTTPS).enabled, Boolean.TRUE);
        serverBuilder.withConfig(SslPolicyConfig.forScope(HTTPS).base_directory, certificates);
    }
    try (Neo4j neo4j = serverBuilder.build()) {
        GraphDatabaseService db = neo4j.defaultDatabaseService();
        assertDbAccessible(db);
        verifyConnector(db, "http", httpEnabled);
        verifyConnector(db, "https", httpsEnabled);
        verifyConnector(db, "bolt", boltEnabled);
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Example 32 with SocketAddress

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

the class DiscoverableURIsTest method shouldLookupBoltPort.

@Test
void shouldLookupBoltPort() {
    var config = Config.newBuilder().set(Map.of(BoltConnector.enabled, true, BoltConnector.advertised_address, new SocketAddress(0))).build();
    var register = new ConnectorPortRegister();
    register.register(BoltConnector.NAME, new InetSocketAddress(1337));
    var discoverables = new DiscoverableURIs.Builder().addBoltEndpoint(config, register).build();
    discoverables.forEach(consumer);
    verify(consumer).accept("bolt_direct", "bolt://localhost:1337");
    verify(consumer).accept("bolt_routing", "neo4j://localhost:1337");
}
Also used : ConnectorPortRegister(org.neo4j.configuration.connectors.ConnectorPortRegister) InetSocketAddress(java.net.InetSocketAddress) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test)

Example 33 with SocketAddress

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

the class DiscoverableURIsTest method shouldOverrideBoltHostWhenHostIsExplicitlySet.

@Test
void shouldOverrideBoltHostWhenHostIsExplicitlySet() {
    var config = Config.newBuilder().set(Map.of(BoltConnector.enabled, true, GraphDatabaseSettings.default_advertised_address, new SocketAddress("myDog.com"), BoltConnector.advertised_address, new SocketAddress("myCat.com", 1234))).build();
    var discoverables = new DiscoverableURIs.Builder().addBoltEndpoint(config, portRegister).build();
    discoverables.forEach(consumer);
    verify(consumer).accept("bolt_direct", "bolt://myCat.com:1234");
    verify(consumer).accept("bolt_routing", "neo4j://myCat.com:1234");
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test)

Example 34 with SocketAddress

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

the class DiscoverableURIsTest method shouldNotSetBoltHostWhenHostIsNotExplicitlySet.

@Test
void shouldNotSetBoltHostWhenHostIsNotExplicitlySet() {
    var config = Config.newBuilder().set(Map.of(BoltConnector.enabled, true, BoltConnector.advertised_address, new SocketAddress(1234))).build();
    var discoverables = new DiscoverableURIs.Builder().addBoltEndpoint(config, portRegister).build();
    discoverables.forEach(consumer);
    verify(consumer).accept("bolt_direct", "bolt://localhost:1234");
    verify(consumer).accept("bolt_routing", "neo4j://localhost:1234");
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test)

Example 35 with SocketAddress

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

the class DiscoverableURIsTest method shouldOverrideBoltEndpoints.

@Test
void shouldOverrideBoltEndpoints() {
    var config = Config.newBuilder().set(Map.of(BoltConnector.enabled, true, // ignored
    GraphDatabaseSettings.default_advertised_address, // ignored
    new SocketAddress("myDog.com"), // ignored
    BoltConnector.advertised_address, // ignored
    new SocketAddress("myCat.com", 1234), ServerSettings.bolt_discoverable_address, URI.create("dog://myDog.com"), ServerSettings.bolt_routing_discoverable_address, URI.create("cat://myCat.com"))).build();
    var discoverables = new DiscoverableURIs.Builder().addBoltEndpoint(config, portRegister).build();
    discoverables.forEach(consumer);
    verify(consumer).accept("bolt_direct", "dog://myDog.com");
    verify(consumer).accept("bolt_routing", "cat://myCat.com");
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) 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