Search in sources :

Example 21 with SocketAddress

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

the class CertificatesIT method setup.

@BeforeEach
public void setup(TestInfo testInfo) throws IOException {
    server.setConfigure(settings -> {
        SslPolicyConfig policy = SslPolicyConfig.forScope(BOLT);
        settings.put(policy.enabled, true);
        settings.put(policy.public_certificate, certFile.toAbsolutePath());
        settings.put(policy.private_key, keyFile.toAbsolutePath());
        settings.put(BoltConnector.enabled, true);
        settings.put(BoltConnector.encryption_level, OPTIONAL);
        settings.put(BoltConnector.listen_address, new SocketAddress("localhost", 0));
    });
    server.init(testInfo);
}
Also used : SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with SocketAddress

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

the class AbstractNeoWebServer method registerHttpsAddressAfterStartup.

private void registerHttpsAddressAfterStartup() {
    if (httpsEnabled) {
        InetSocketAddress localHttpsAddress = webServer.getLocalHttpsAddress();
        connectorPortRegister.register(HttpsConnector.NAME, localHttpsAddress);
        if (httpsAdvertisedAddress.getPort() == 0) {
            httpsAdvertisedAddress = new SocketAddress(localHttpsAddress.getHostString(), localHttpsAddress.getPort());
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) InetSocketAddress(java.net.InetSocketAddress) SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Example 23 with SocketAddress

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

the class Jetty9WebServerIT method shouldBeAbleToUsePortZero.

@Test
public void shouldBeAbleToUsePortZero() throws Exception {
    // Given
    webServer = new Jetty9WebServer(NullLogProvider.getInstance(), Config.defaults(), NetworkConnectionTracker.NO_OP, mock(ByteBufferPool.class));
    webServer.setHttpAddress(new SocketAddress("localhost", 0));
    // When
    webServer.start();
// Then no exception
}
Also used : Jetty9WebServer(org.neo4j.server.web.Jetty9WebServer) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.Test)

Example 24 with SocketAddress

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

the class WebContainerConfigIT method shouldPickUpAddressFromConfig.

@Test
public void shouldPickUpAddressFromConfig() throws Exception {
    var nonDefaultAddress = new SocketAddress("0.0.0.0", 0);
    testWebContainer = CommunityWebContainerBuilder.builder().onAddress(nonDefaultAddress).usingDataDir(folder.directory(name.getMethodName()).toAbsolutePath().toString()).build();
    GraphDatabaseAPI database = testWebContainer.getDefaultDatabase();
    var localHttpAddress = PortUtils.getConnectorAddress(database, "http");
    assertNotEquals(HttpConnector.DEFAULT_PORT, localHttpAddress.getPort());
    assertEquals(nonDefaultAddress.getHostname(), localHttpAddress.getHost());
    var request = HttpRequest.newBuilder(testWebContainer.getBaseUri()).GET().build();
    var response = newHttpClient().send(request, discarding());
    assertThat(response.statusCode()).isEqualTo(200);
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Test(org.junit.Test)

Example 25 with SocketAddress

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

the class TestBackup method before.

@Before
public void before() throws IOException {
    Files.createDirectories(backupDirectory);
    managementService = new EnterpriseDatabaseManagementServiceBuilder(databaseDirectory).setConfig(Collections.singletonMap(OnlineBackupSettings.online_backup_listen_address, new SocketAddress("127.0.0.1", backupPort))).build();
}
Also used : EnterpriseDatabaseManagementServiceBuilder(com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) Before(org.junit.Before)

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