Search in sources :

Example 6 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldSupportMultipleBoltConnectorsWithDefaultAndCustomName.

@Test
public void shouldSupportMultipleBoltConnectorsWithDefaultAndCustomName() throws Exception {
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.bolt.type", "BOLT", "dbms.connector.bolt.enabled", "true", "dbms.connector.bolt.listen_address", ":8000", "dbms.connector.bolt2.type", "BOLT", "dbms.connector.bolt2.enabled", "true", "dbms.connector.bolt2.listen_address", ":9000"));
    // when
    BoltConnector boltConnector1 = config.boltConnectors().get(0);
    BoltConnector boltConnector2 = config.boltConnectors().get(1);
    // then
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(boltConnector1.listen_address));
    assertEquals(new ListenSocketAddress("localhost", 9000), config.get(boltConnector2.listen_address));
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 7 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldEnableBoltByDefault.

@Test
public void shouldEnableBoltByDefault() throws Exception {
    // given
    Config config = Config.serverDefaults();
    // when
    BoltConnector boltConnector = config.boltConnectors().get(0);
    ListenSocketAddress listenSocketAddress = config.get(boltConnector.listen_address);
    // then
    assertEquals(new ListenSocketAddress("localhost", 7687), listenSocketAddress);
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 8 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method testServerDefaultSettings.

/// JONAS HTTP FOLLOWS
@Test
public void testServerDefaultSettings() throws Exception {
    // given
    Config config = Config.serverDefaults();
    // when
    List<HttpConnector> connectors = config.httpConnectors();
    // then
    assertEquals(2, connectors.size());
    if (connectors.get(0).encryptionLevel().equals(TLS)) {
        assertEquals(new ListenSocketAddress("localhost", 7474), config.get(connectors.get(1).listen_address));
        assertEquals(new ListenSocketAddress("localhost", 7473), config.get(connectors.get(0).listen_address));
    } else {
        assertEquals(new ListenSocketAddress("localhost", 7474), config.get(connectors.get(0).listen_address));
        assertEquals(new ListenSocketAddress("localhost", 7473), config.get(connectors.get(1).listen_address));
    }
}
Also used : HttpConnector(org.neo4j.kernel.configuration.HttpConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 9 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldSupportMultipleBoltConnectorsWithCustomNames.

@Test
public void shouldSupportMultipleBoltConnectorsWithCustomNames() throws Exception {
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.bolt1.type", "BOLT", "dbms.connector.bolt1.enabled", "true", "dbms.connector.bolt1.listen_address", ":8000", "dbms.connector.bolt2.type", "BOLT", "dbms.connector.bolt2.enabled", "true", "dbms.connector.bolt2.listen_address", ":9000"));
    // when
    List<ListenSocketAddress> addresses = config.boltConnectors().stream().map(c -> config.get(c.listen_address)).collect(Collectors.toList());
    // then
    assertEquals(2, addresses.size());
    if (addresses.get(0).getPort() == 8000) {
        assertEquals(new ListenSocketAddress("localhost", 8000), addresses.get(0));
        assertEquals(new ListenSocketAddress("localhost", 9000), addresses.get(1));
    } else {
        assertEquals(new ListenSocketAddress("localhost", 8000), addresses.get(1));
        assertEquals(new ListenSocketAddress("localhost", 9000), addresses.get(0));
    }
}
Also used : HashMap(java.util.HashMap) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) HttpConnector(org.neo4j.kernel.configuration.HttpConnector) Assert.assertThat(org.junit.Assert.assertThat) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Assert.fail(org.junit.Assert.fail) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) InvalidSettingException(org.neo4j.graphdb.config.InvalidSettingException) ByteUnit(org.neo4j.io.ByteUnit) Config(org.neo4j.kernel.configuration.Config) Matchers.empty(org.hamcrest.Matchers.empty) TLS(org.neo4j.kernel.configuration.HttpConnector.Encryption.TLS) BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Setting(org.neo4j.graphdb.config.Setting) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) Assert.assertEquals(org.junit.Assert.assertEquals) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 10 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldStillSupportCustomNameForBoltConnector.

@Test
public void shouldStillSupportCustomNameForBoltConnector() throws Exception {
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.random_name_that_will_be_unsupported.type", "BOLT", "dbms.connector.random_name_that_will_be_unsupported.enabled", "true", "dbms.connector.random_name_that_will_be_unsupported.listen_address", ":8000"));
    // when
    BoltConnector boltConnector = config.boltConnectors().get(0);
    // then
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(boltConnector.listen_address));
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Aggregations

ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)26 Test (org.junit.Test)23 Config (org.neo4j.kernel.configuration.Config)15 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)8 AdvertisedSocketAddress (org.neo4j.helpers.AdvertisedSocketAddress)4 HttpConnector (org.neo4j.kernel.configuration.HttpConnector)4 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 NettyServer (org.neo4j.bolt.transport.NettyServer)2 Configuration (org.neo4j.graphdb.config.Configuration)2 Setting (org.neo4j.graphdb.config.Setting)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)2 InterfacesConfig (com.hazelcast.config.InterfacesConfig)1 JoinConfig (com.hazelcast.config.JoinConfig)1 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)1 NetworkConfig (com.hazelcast.config.NetworkConfig)1