use of org.neo4j.driver.Config in project beam by apache.
the class Neo4jIOTest method testDriverConfigurationWith.
@Test
public void testDriverConfigurationWith() throws Exception {
Neo4jIO.DriverConfiguration driverConfiguration = Neo4jIO.DriverConfiguration.create();
Config config = Config.builder().withEncryption().withConnectionAcquisitionTimeout(54321L, TimeUnit.MILLISECONDS).withConnectionTimeout(43210L, TimeUnit.MILLISECONDS).withConnectionLivenessCheckTimeout(32109L, TimeUnit.MILLISECONDS).withMaxConnectionLifetime(21098L, TimeUnit.MILLISECONDS).withMaxConnectionPoolSize(101).build();
driverConfiguration = driverConfiguration.withConfig(config);
Config configVerify = driverConfiguration.getConfig();
Assert.assertNotNull(configVerify);
Assert.assertEquals(true, configVerify.encrypted());
Assert.assertEquals(54321L, configVerify.connectionAcquisitionTimeoutMillis());
Assert.assertEquals(43210L, configVerify.connectionTimeoutMillis());
Assert.assertEquals(32109L, configVerify.idleTimeBeforeConnectionTest());
Assert.assertEquals(21098L, configVerify.maxConnectionLifetimeMillis());
Assert.assertEquals(101, configVerify.maxConnectionPoolSize());
driverConfiguration = driverConfiguration.withUrl("url1");
Assert.assertEquals("url1", driverConfiguration.getUrl().get());
// URL and URLs can be set independently but are both used
driverConfiguration = driverConfiguration.withUrls(Arrays.asList("url2", "url3", "url4"));
Assert.assertEquals(3, driverConfiguration.getUrls().get().size());
driverConfiguration = driverConfiguration.withUsername("username");
Assert.assertEquals("username", driverConfiguration.getUsername().get());
driverConfiguration = driverConfiguration.withPassword("password");
Assert.assertEquals("password", driverConfiguration.getPassword().get());
}
use of org.neo4j.driver.Config in project spring-boot by spring-projects.
the class Neo4jAutoConfiguration method mapDriverConfig.
Config mapDriverConfig(Neo4jProperties properties, List<ConfigBuilderCustomizer> customizers) {
Config.ConfigBuilder builder = Config.builder();
configurePoolSettings(builder, properties.getPool());
URI uri = properties.getUri();
String scheme = (uri != null) ? uri.getScheme() : "bolt";
configureDriverSettings(builder, properties, isSimpleScheme(scheme));
builder.withLogging(new Neo4jSpringJclLogging());
customizers.forEach((customizer) -> customizer.customize(builder));
return builder.build();
}
use of org.neo4j.driver.Config in project jmeter by apache.
the class BoltConnectionElement method testStarted.
@Override
public void testStarted() {
this.setRunningVersion(true);
TestBeanHelper.prepare(this);
JMeterVariables variables = getThreadContext().getVariables();
if (variables.getObject(BOLT_CONNECTION) != null) {
log.error("Bolt connection already exists");
} else {
synchronized (this) {
Config config = Config.builder().withMaxConnectionPoolSize(getMaxConnectionPoolSize()).build();
driver = GraphDatabase.driver(getBoltUri(), AuthTokens.basic(getUsername(), getPassword()), config);
variables.putObject(BOLT_CONNECTION, driver);
}
}
}
use of org.neo4j.driver.Config in project spring-boot by spring-projects.
the class Neo4jPropertiesTests method driverSettingsHaveConsistentDefaults.
@Test
void driverSettingsHaveConsistentDefaults() {
Config defaultConfig = Config.defaultConfig();
Neo4jProperties properties = new Neo4jProperties();
assertDuration(properties.getConnectionTimeout(), defaultConfig.connectionTimeoutMillis());
assertDuration(properties.getMaxTransactionRetryTime(), RetrySettings.DEFAULT.maxRetryTimeMs());
}
use of org.neo4j.driver.Config in project spring-boot by spring-projects.
the class Neo4jPropertiesTests method securitySettingsHaveConsistentDefaults.
@Test
void securitySettingsHaveConsistentDefaults() {
Config defaultConfig = Config.defaultConfig();
Neo4jProperties properties = new Neo4jProperties();
assertThat(properties.getSecurity().isEncrypted()).isEqualTo(defaultConfig.encrypted());
assertThat(properties.getSecurity().getTrustStrategy().name()).isEqualTo(defaultConfig.trustStrategy().strategy().name());
assertThat(properties.getSecurity().isHostnameVerificationEnabled()).isEqualTo(defaultConfig.trustStrategy().isHostnameVerificationEnabled());
}
Aggregations