Search in sources :

Example 1 with HttpConnector

use of org.neo4j.kernel.configuration.HttpConnector 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 2 with HttpConnector

use of org.neo4j.kernel.configuration.HttpConnector in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldBeAbleToOverrideHttpListenAddressWithJustOneParameter.

@Test
public void shouldBeAbleToOverrideHttpListenAddressWithJustOneParameter() throws Exception {
    // given
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.http.enabled", "true", "dbms.connector.http.listen_address", ":8000"));
    // then
    assertEquals(1, config.enabledHttpConnectors().size());
    HttpConnector httpConnector = config.enabledHttpConnectors().get(0);
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(httpConnector.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 3 with HttpConnector

use of org.neo4j.kernel.configuration.HttpConnector in project neo4j by neo4j.

the class ConnectionInfoIT method hzTest.

@Test
public void hzTest() throws Throwable {
    // given
    testSocket = bindPort("0.0.0.0", 4243);
    //when
    AssertableLogProvider logProvider = new AssertableLogProvider();
    AssertableLogProvider userLogProvider = new AssertableLogProvider();
    HazelcastDiscoveryServiceFactory hzFactory = new HazelcastDiscoveryServiceFactory();
    Config config = embeddedDefaults(stringMap(discovery_listen_address.name(), ":" + testSocket.getLocalPort(), CausalClusteringSettings.initial_discovery_members.name(), "localhost:" + testSocket.getLocalPort(), new BoltConnector("bolt").enabled.name(), "true", new HttpConnector("http").enabled.name(), "true"));
    Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
    jobScheduler.init();
    CoreTopologyService coreTopologyService = hzFactory.coreTopologyService(config, new MemberId(UUID.randomUUID()), jobScheduler, logProvider, userLogProvider);
    try {
        coreTopologyService.init();
        coreTopologyService.start();
    }//then
     catch (Throwable throwable) {
    //expected
    }
    logProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
    userLogProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
}
Also used : Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) MemberId(org.neo4j.causalclustering.identity.MemberId) HttpConnector(org.neo4j.kernel.configuration.HttpConnector) HazelcastDiscoveryServiceFactory(org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory) CoreTopologyService(org.neo4j.causalclustering.discovery.CoreTopologyService) BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 4 with HttpConnector

use of org.neo4j.kernel.configuration.HttpConnector in project neo4j by neo4j.

the class CommunityServerBuilder method createConfiguration.

private Map<String, String> createConfiguration(File temporaryFolder) {
    Map<String, String> properties = stringMap(ServerSettings.management_api_path.name(), managementUri, ServerSettings.rest_api_path.name(), restUri);
    ServerTestUtils.addDefaultRelativeProperties(properties, temporaryFolder);
    if (dataDir != null) {
        properties.put(DatabaseManagementSystemSettings.data_directory.name(), dataDir);
    }
    if (maxThreads != null) {
        properties.put(ServerSettings.webserver_max_threads.name(), maxThreads);
    }
    if (thirdPartyPackages.keySet().size() > 0) {
        properties.put(ServerSettings.third_party_packages.name(), asOneLine(thirdPartyPackages));
    }
    if (autoIndexedNodeKeys != null && autoIndexedNodeKeys.length > 0) {
        properties.put("dbms.auto_index.nodes.enabled", "true");
        String propertyKeys = org.apache.commons.lang.StringUtils.join(autoIndexedNodeKeys, ",");
        properties.put("dbms.auto_index.nodes.keys", propertyKeys);
    }
    if (autoIndexedRelationshipKeys != null && autoIndexedRelationshipKeys.length > 0) {
        properties.put("dbms.auto_index.relationships.enabled", "true");
        String propertyKeys = org.apache.commons.lang.StringUtils.join(autoIndexedRelationshipKeys, ",");
        properties.put("dbms.auto_index.relationships.keys", propertyKeys);
    }
    if (securityRuleClassNames != null && securityRuleClassNames.length > 0) {
        String propertyKeys = org.apache.commons.lang.StringUtils.join(securityRuleClassNames, ",");
        properties.put(ServerSettings.security_rules.name(), propertyKeys);
    }
    HttpConnector httpConnector = new HttpConnector("http", Encryption.NONE);
    HttpConnector httpsConnector = new HttpConnector("https", Encryption.TLS);
    properties.put(httpConnector.type.name(), "HTTP");
    properties.put(httpConnector.enabled.name(), "true");
    properties.put(httpConnector.address.name(), address.toString());
    properties.put(httpConnector.encryption.name(), "NONE");
    properties.put(httpsConnector.type.name(), "HTTP");
    properties.put(httpsConnector.enabled.name(), String.valueOf(httpsEnabled));
    properties.put(httpsConnector.address.name(), httpsAddress.toString());
    properties.put(httpsConnector.encryption.name(), "TLS");
    properties.put(GraphDatabaseSettings.auth_enabled.name(), "false");
    properties.put(ServerSettings.certificates_directory.name(), new File(temporaryFolder, "certificates").getAbsolutePath());
    properties.put(GraphDatabaseSettings.logs_directory.name(), new File(temporaryFolder, "logs").getAbsolutePath());
    properties.put(GraphDatabaseSettings.pagecache_memory.name(), "8m");
    for (Object key : arbitraryProperties.keySet()) {
        properties.put(String.valueOf(key), String.valueOf(arbitraryProperties.get(key)));
    }
    return properties;
}
Also used : HttpConnector(org.neo4j.kernel.configuration.HttpConnector) File(java.io.File)

Example 5 with HttpConnector

use of org.neo4j.kernel.configuration.HttpConnector in project neo4j by neo4j.

the class DatabaseActionsTest method createFiles.

@Before
public void createFiles() throws IOException {
    storeDir = new File(testDirectory.directory(), "store_dir");
    storeDir.mkdirs();
    configFile = new File(testDirectory.directory(), "neo4j.conf");
    Properties props = new Properties();
    props.setProperty(new HttpConnector("http").type.name(), "HTTP");
    props.setProperty(new HttpConnector("http").encryption.name(), "NONE");
    props.setProperty(new HttpConnector("http").enabled.name(), "true");
    try (FileWriter writer = new FileWriter(configFile)) {
        props.store(writer, "");
    }
}
Also used : HttpConnector(org.neo4j.kernel.configuration.HttpConnector) FileWriter(java.io.FileWriter) Properties(java.util.Properties) File(java.io.File) Before(org.junit.Before)

Aggregations

HttpConnector (org.neo4j.kernel.configuration.HttpConnector)9 Test (org.junit.Test)5 Config (org.neo4j.kernel.configuration.Config)4 File (java.io.File)3 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)3 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)2 FileWriter (java.io.FileWriter)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 CoreTopologyService (org.neo4j.causalclustering.discovery.CoreTopologyService)1 HazelcastDiscoveryServiceFactory (org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory)1 MemberId (org.neo4j.causalclustering.identity.MemberId)1 Neo4jJobScheduler (org.neo4j.kernel.impl.util.Neo4jJobScheduler)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1