Search in sources :

Example 1 with SocketAddress

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

the class GraphDatabaseSettingsTest method shouldDeriveBoltListenAddressFromDefaultListenAddressAndSpecifiedPort.

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

Example 2 with SocketAddress

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

the class GraphDatabaseSettingsTest method shouldDeriveBoltListenAddressFromDefaultListenAddress.

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

Example 3 with SocketAddress

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

the class GraphDatabaseSettingsTest method testDefaultAddressMigration.

@Test
void testDefaultAddressMigration() {
    String oldDefaultListen = "dbms.connectors.default_listen_address";
    String oldDefaultAdvertised = "dbms.connectors.default_advertised_address";
    var config = Config.newBuilder().setRaw(Map.of(oldDefaultListen, "foo", oldDefaultAdvertised, "bar")).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThrows(IllegalArgumentException.class, () -> config.getSetting(oldDefaultListen));
    assertThrows(IllegalArgumentException.class, () -> config.getSetting(oldDefaultAdvertised));
    assertEquals(new SocketAddress("foo"), config.get(default_listen_address));
    assertEquals(new SocketAddress("bar"), config.get(default_advertised_address));
    var messageMatcher = assertThat(logProvider).forClass(Config.class).forLevel(WARN);
    messageMatcher.containsMessageWithArguments("Use of deprecated setting %s. It is replaced by %s", oldDefaultListen, default_listen_address.name()).containsMessageWithArguments("Use of deprecated setting %s. It is replaced by %s", oldDefaultAdvertised, default_advertised_address.name());
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 4 with SocketAddress

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

the class SettingTest method testSocketSolve.

@Test
void testSocketSolve() {
    var setting = (SettingImpl<SocketAddress>) setting("setting", SOCKET_ADDRESS);
    assertEquals(new SocketAddress("localhost", 7473), setting.solveDependency(setting.parse("localhost:7473"), setting.parse("127.0.0.1:7474")));
    assertEquals(new SocketAddress("127.0.0.1", 7473), setting.solveDependency(setting.parse(":7473"), setting.parse("127.0.0.1:7474")));
    assertEquals(new SocketAddress("127.0.0.1", 7473), setting.solveDependency(setting.parse(":7473"), setting.parse("127.0.0.1")));
    assertEquals(new SocketAddress("localhost", 7474), setting.solveDependency(setting.parse("localhost"), setting.parse(":7474")));
    assertEquals(new SocketAddress("localhost", 7474), setting.solveDependency(setting.parse("localhost"), setting.parse("127.0.0.1:7474")));
    assertEquals(new SocketAddress("localhost", 7474), setting.solveDependency(null, setting.parse("localhost:7474")));
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 5 with SocketAddress

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

the class SettingTest method testSocket.

@Test
void testSocket() {
    var setting = (SettingImpl<SocketAddress>) setting("setting", SOCKET_ADDRESS);
    assertEquals(new SocketAddress("127.0.0.1", 7474), setting.parse("127.0.0.1:7474"));
    assertEquals(new SocketAddress("127.0.0.1", 7474), setting.parse(" 127.0.0.1:7474 "));
    assertEquals(new SocketAddress("127.0.0.1", -1), setting.parse("127.0.0.1"));
    assertEquals(new SocketAddress(null, 7474), setting.parse(":7474"));
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

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