Search in sources :

Example 6 with Config

use of org.neo4j.driver.Config in project spring-boot by spring-projects.

the class Neo4jPropertiesTests method poolSettingsHaveConsistentDefaults.

@Test
void poolSettingsHaveConsistentDefaults() {
    Config defaultConfig = Config.defaultConfig();
    Pool pool = new Neo4jProperties().getPool();
    assertThat(pool.isMetricsEnabled()).isEqualTo(defaultConfig.isMetricsEnabled());
    assertThat(pool.isLogLeakedSessions()).isEqualTo(defaultConfig.logLeakedSessions());
    assertThat(pool.getMaxConnectionPoolSize()).isEqualTo(defaultConfig.maxConnectionPoolSize());
    assertDuration(pool.getIdleTimeBeforeConnectionTest(), defaultConfig.idleTimeBeforeConnectionTest());
    assertDuration(pool.getMaxConnectionLifetime(), defaultConfig.maxConnectionLifetimeMillis());
    assertDuration(pool.getConnectionAcquisitionTimeout(), defaultConfig.connectionAcquisitionTimeoutMillis());
}
Also used : Config(org.neo4j.driver.Config) Pool(org.springframework.boot.autoconfigure.neo4j.Neo4jProperties.Pool) Test(org.junit.jupiter.api.Test)

Example 7 with Config

use of org.neo4j.driver.Config in project spring-boot by spring-projects.

the class Neo4jAutoConfiguration method neo4jDriver.

@Bean
@ConditionalOnMissingBean
public Driver neo4jDriver(Neo4jProperties properties, Environment environment, ObjectProvider<ConfigBuilderCustomizer> configBuilderCustomizers) {
    AuthToken authToken = mapAuthToken(properties.getAuthentication(), environment);
    Config config = mapDriverConfig(properties, configBuilderCustomizers.orderedStream().collect(Collectors.toList()));
    URI serverUri = determineServerUri(properties, environment);
    return GraphDatabase.driver(serverUri, authToken, config);
}
Also used : Config(org.neo4j.driver.Config) AuthToken(org.neo4j.driver.AuthToken) URI(java.net.URI) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with Config

use of org.neo4j.driver.Config in project neo4j by neo4j.

the class BoltStateHandlerTest method fallbackTest.

private void fallbackTest(String initialScheme, String fallbackScheme, Runnable failer) throws CommandException {
    final String[] uriScheme = new String[1];
    RecordingDriverProvider provider = new RecordingDriverProvider() {

        @Override
        public Driver apply(String uri, AuthToken authToken, Config config) {
            uriScheme[0] = uri.substring(0, uri.indexOf(':'));
            if (uriScheme[0].equals(initialScheme)) {
                failer.run();
            }
            super.apply(uri, authToken, config);
            return new FakeDriver();
        }
    };
    BoltStateHandler handler = new BoltStateHandler(provider, false);
    ConnectionConfig config = new ConnectionConfig(initialScheme, "", -1, "", "", Encryption.DEFAULT, ABSENT_DB_NAME);
    handler.connect(config);
    assertEquals(fallbackScheme, uriScheme[0]);
}
Also used : ConnectionConfig(org.neo4j.shell.ConnectionConfig) Config(org.neo4j.driver.Config) SessionConfig(org.neo4j.driver.SessionConfig) AuthToken(org.neo4j.driver.AuthToken) FakeDriver(org.neo4j.shell.test.bolt.FakeDriver) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ConnectionConfig(org.neo4j.shell.ConnectionConfig)

Aggregations

Config (org.neo4j.driver.Config)8 Test (org.junit.jupiter.api.Test)3 URI (java.net.URI)2 AuthToken (org.neo4j.driver.AuthToken)2 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 SessionConfig (org.neo4j.driver.SessionConfig)1 ConnectionConfig (org.neo4j.shell.ConnectionConfig)1 FakeDriver (org.neo4j.shell.test.bolt.FakeDriver)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Pool (org.springframework.boot.autoconfigure.neo4j.Neo4jProperties.Pool)1 Bean (org.springframework.context.annotation.Bean)1