@Test public void shouldLoadBoltDriverConfigFromPropertiesFile() { Configuration driverConfig = new Configuration.Builder( new ClasspathConfigurationSource("bolt.driver.properties")).build(); assertThat(driverConfig.getURI()).isEqualTo("bolt://localhost"); assertThat(driverConfig.getConnectionPoolSize()).isEqualTo(150); assertThat(driverConfig.getEncryptionLevel()).isEqualTo("NONE"); assertThat(driverConfig.getTrustStrategy()).isEqualTo("TRUST_ON_FIRST_USE"); assertThat(driverConfig.getTrustCertFile()).isEqualTo("/tmp/cert"); }
private BoltConfig getBoltConfiguration() { BoltConfig boltConfig = new BoltConfig(); if (configuration.getEncryptionLevel() != null) { try { boltConfig.encryptionLevel = Config.EncryptionLevel .valueOf(configuration.getEncryptionLevel().toUpperCase()); } catch (IllegalArgumentException iae) { LOGGER.debug("Invalid configuration for the Bolt Driver Encryption Level: {}", configuration.getEncryptionLevel()); throw iae; } } boltConfig.sessionPoolSize = configuration.getConnectionPoolSize(); if (configuration.getTrustStrategy() != null) { try { boltConfig.trustStrategy = Config.TrustStrategy.Strategy.valueOf(configuration.getTrustStrategy()); } catch (IllegalArgumentException iae) { LOGGER.debug("Invalid configuration for the Bolt Driver Trust Strategy: {}", configuration.getTrustStrategy()); throw iae; } } if (configuration.getTrustCertFile() != null) { boltConfig.trustCertFile = configuration.getTrustCertFile(); } if (configuration.getConnectionLivenessCheckTimeout() != null) { boltConfig.connectionLivenessCheckTimeout = configuration.getConnectionLivenessCheckTimeout(); } return boltConfig; }
private BoltConfig getBoltConfiguration(Configuration configuration) { BoltConfig boltConfig = new BoltConfig(); if (configuration.getEncryptionLevel() != null) { try { boltConfig.encryptionLevel = Config.EncryptionLevel .valueOf(configuration.getEncryptionLevel().toUpperCase()); } catch (IllegalArgumentException iae) { LOGGER.debug("Invalid configuration for the Bolt Driver Encryption Level: {}", configuration.getEncryptionLevel()); throw iae; } } boltConfig.sessionPoolSize = configuration.getConnectionPoolSize(); if (configuration.getTrustStrategy() != null) { try { boltConfig.trustStrategy = Config.TrustStrategy.Strategy.valueOf(configuration.getTrustStrategy()); } catch (IllegalArgumentException iae) { LOGGER.debug("Invalid configuration for the Bolt Driver Trust Strategy: {}", configuration.getTrustStrategy()); throw iae; } } if (configuration.getTrustCertFile() != null) { boltConfig.trustCertFile = configuration.getTrustCertFile(); } if (configuration.getConnectionLivenessCheckTimeout() != null) { boltConfig.connectionLivenessCheckTimeout = configuration.getConnectionLivenessCheckTimeout(); } return boltConfig; }
@Test public void shouldConfigureFromNameSpacePropertiesFile() { Configuration configuration = new Configuration.Builder( new ClasspathConfigurationSource("ogm-namespace.properties")).build(); assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.DUMP); assertThat(configuration.getDumpDir()).isEqualTo("hello"); assertThat(configuration.getDumpFilename()).isEqualTo("generated-indexes2.cql"); assertThat(configuration.getDriverClassName()).isEqualTo("org.neo4j.ogm.drivers.http.driver.HttpDriver"); assertThat(configuration.getCredentials().credentials().toString()).isEqualTo("bmVvNGo6cGFzc3dvcmQ="); assertThat(configuration.getURI()).isEqualTo("http://localhost:7474"); assertThat(configuration.getConnectionPoolSize()).isEqualTo(100); assertThat(configuration.getEncryptionLevel()).isEqualTo("NONE"); assertThat(configuration.getTrustStrategy()).isEqualTo("TRUST_ON_FIRST_USE"); assertThat(configuration.getTrustCertFile()).isEqualTo("/tmp/cert"); }
@Test public void shouldConfigureProgrammatically() { Configuration.Builder builder = new Configuration.Builder(); builder.autoIndex("assert"); builder.generatedIndexesOutputDir("dir"); builder.generatedIndexesOutputFilename("filename"); builder.credentials("fred", "flintstone"); builder.uri("http://localhost:8080"); builder.connectionPoolSize(200); builder.encryptionLevel("REQUIRED"); builder.trustStrategy("TRUST_SIGNED_CERTIFICATES"); builder.trustCertFile("/tmp/cert"); builder.connectionLivenessCheckTimeout(1000); Configuration configuration = builder.build(); assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.ASSERT); assertThat(configuration.getDumpDir()).isEqualTo("dir"); assertThat(configuration.getDumpFilename()).isEqualTo("filename"); assertThat(configuration.getDriverClassName()).isEqualTo("org.neo4j.ogm.drivers.http.driver.HttpDriver"); assertThat(configuration.getCredentials().credentials().toString()).isEqualTo("ZnJlZDpmbGludHN0b25l"); assertThat(configuration.getURI()).isEqualTo("http://localhost:8080"); assertThat(configuration.getConnectionPoolSize()).isEqualTo(200); assertThat(configuration.getEncryptionLevel()).isEqualTo("REQUIRED"); assertThat(configuration.getTrustStrategy()).isEqualTo("TRUST_SIGNED_CERTIFICATES"); assertThat(configuration.getTrustCertFile()).isEqualTo("/tmp/cert"); assertThat(configuration.getConnectionLivenessCheckTimeout().intValue()).isEqualTo(1000); }