本文整理了Java中org.neo4j.kernel.configuration.Config.get()
方法的一些代码示例,展示了Config.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.get()
方法的具体详情如下:
包路径:org.neo4j.kernel.configuration.Config
类名称:Config
方法名:get
[英]Retrieves a configuration value. If no value is configured, a default value will be returned instead. Note that null is a valid value.
[中]检索配置值。如果未配置任何值,将返回默认值。请注意,null是一个有效值。
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldApplyDefaults()
{
Config config = Config();
assertThat( config.get( MySettingsWithDefaults.hello ), is( "Hello, World!" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSetSecretParameter()
{
// Given
Config config = Config.builder()
.withSetting( MySettingsWithDefaults.password, "this should not be visible" )
.withSetting( MySettingsWithDefaults.hello, "ABC" )
.withConfigClasses( Arrays.asList( mySettingsWithDefaults, myMigratingSettings ) )
.build();
// Then
assertTrue( config.getConfigValues().get( MySettingsWithDefaults.password.name() ).secret() );
assertFalse( config.getConfigValues().get( MySettingsWithDefaults.hello.name() ).secret() );
String configText = config.toString();
assertTrue( configText.contains( Secret.OBSFUCATED ) );
assertFalse( configText.contains( "this should not be visible" ) );
assertFalse( configText.contains( config.get( MySettingsWithDefaults.password ) ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToGetLocation() throws Throwable
{
theDatabase.start();
assertThat( theDatabase.getLocation().getAbsolutePath(),
is( dbConfig.get( GraphDatabaseSettings.database_path ).getAbsolutePath() ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void augmentDefaults()
{
Config config = Config();
assertEquals( "Hello, World!", config.get( MySettingsWithDefaults.hello ) );
config.augmentDefaults( MySettingsWithDefaults.hello, "new default" );
assertEquals( "new default", config.get( MySettingsWithDefaults.hello ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeEnabledByDefault()
{
assertTrue( configuration.config( settingsClasses ).get( udc_enabled ) );
assertTrue( Config.defaults().get( udc_enabled ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void overrideDefaultValuesForCurrentFormat()
{
Config config = Config.defaults();
int testHeaderSize = 17;
ResizableRecordFormats recordFormats = new ResizableRecordFormats( testHeaderSize );
new RecordFormatPropertyConfigurator( recordFormats, config ).configure();
assertEquals( DEFAULT_BLOCK_SIZE - testHeaderSize, config.get( string_block_size ).intValue() );
assertEquals( DEFAULT_BLOCK_SIZE - testHeaderSize, config.get( array_block_size ).intValue() );
assertEquals( DEFAULT_LABEL_BLOCK_SIZE - testHeaderSize, config.get( label_block_size ).intValue() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToAugmentConfig()
{
// Given
Config config = Config();
// When
config.augment( MySettingsWithDefaults.boolSetting, Settings.FALSE );
config.augment( MySettingsWithDefaults.hello, "Bye" );
// Then
assertThat( config.get( MySettingsWithDefaults.boolSetting ), equalTo( false ) );
assertThat( config.get( MySettingsWithDefaults.hello ), equalTo( "Bye" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldApplyMigrations()
{
// When
Config config = Config( stringMap( "old", "hello!" ) );
// Then
assertThat( config.get( MyMigratingSettings.newer ), is( "hello!" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception
{
// given
DatabaseLayout databaseLayout = testDirectory.databaseLayout();
String[] args = {databaseLayout.databaseDirectory().getAbsolutePath()};
ConsistencyCheckService service = mock( ConsistencyCheckService.class );
// when
runConsistencyCheckToolWith( service, args );
// then
ArgumentCaptor<Config> config = ArgumentCaptor.forClass( Config.class );
verify( service ).runFullConsistencyCheck( eq( databaseLayout ), config.capture(),
any( ProgressMonitorFactory.class ), any( LogProvider.class ), any( FileSystemAbstraction.class ),
anyBoolean(), any( ConsistencyFlags.class ) );
assertFalse( config.getValue().get( ConsistencyCheckSettings.consistency_check_property_owners ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void passesOnConfigurationIfProvided() throws Exception
{
// given
DatabaseLayout databaseLayout = testDirectory.databaseLayout();
File configFile = testDirectory.file( Config.DEFAULT_CONFIG_FILE_NAME );
Properties properties = new Properties();
properties.setProperty( ConsistencyCheckSettings.consistency_check_property_owners.name(), "true" );
properties.store( new FileWriter( configFile ), null );
String[] args = {databaseLayout.databaseDirectory().getAbsolutePath(), "-config", configFile.getPath()};
ConsistencyCheckService service = mock( ConsistencyCheckService.class );
// when
runConsistencyCheckToolWith( service, args );
// then
ArgumentCaptor<Config> config = ArgumentCaptor.forClass( Config.class );
verify( service ).runFullConsistencyCheck( eq( databaseLayout ), config.capture(),
any( ProgressMonitorFactory.class ), any( LogProvider.class ), any( FileSystemAbstraction.class ),
anyBoolean(), any(ConsistencyFlags.class) );
assertTrue( config.getValue().get( ConsistencyCheckSettings.consistency_check_property_owners ) );
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Test
public void shouldRegisterAtRootByDefault() throws Exception
{
WebServer webServer = mock( WebServer.class );
Config config = mock( Config.class );
CommunityNeoServer neoServer = mock( CommunityNeoServer.class );
when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) );
when( neoServer.getWebServer() ).thenReturn( webServer );
when( config.get( GraphDatabaseSettings.auth_enabled ) ).thenReturn( true );
DBMSModule module = new DBMSModule( webServer, config, () -> new DiscoverableURIs.Builder().build() );
module.start();
verify( webServer ).addJAXRSClasses( anyList(), anyString(), isNull() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void keepUserDefinedFormatConfig()
{
Config config = Config.defaults( string_block_size, "36" );
RecordFormats recordFormats = Standard.LATEST_RECORD_FORMATS;
new RecordFormatPropertyConfigurator( recordFormats, config ).configure();
assertEquals( "Should keep used specified value", 36, config.get( string_block_size ).intValue() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception
{
// Given
WebServer webServer = mock( WebServer.class );
CommunityNeoServer neoServer = mock( CommunityNeoServer.class );
when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) );
when( neoServer.getWebServer() ).thenReturn( webServer );
Database database = mock( Database.class );
when( neoServer.getDatabase() ).thenReturn( database );
Config config = mock( Config.class );
List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<>();
String path = "/third/party/package";
jaxRsPackages.add( new ThirdPartyJaxRsPackage( "org.example.neo4j", path ) );
when( config.get( ServerSettings.third_party_packages ) ).thenReturn( jaxRsPackages );
// When
ThirdPartyJAXRSModule module =
new ThirdPartyJAXRSModule( webServer, config, NullLogProvider.getInstance(), neoServer );
module.start();
// Then
verify( webServer ).addJAXRSPackages( any( List.class ), anyString(), anyCollection() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAcquireSchemaWriteLockBeforeCreatingUniquenessConstraint() throws Exception
{
// given
String defaultProvider = Config.defaults().get( default_schema_provider );
when( constraintIndexCreator.createUniquenessConstraintIndex( transaction, descriptor, defaultProvider ) ).thenReturn( 42L );
when( storageReader.constraintsGetForSchema( descriptor.schema() ) ).thenReturn( Collections.emptyIterator() );
// when
operations.uniquePropertyConstraintCreate( descriptor );
// then
order.verify( locks ).acquireExclusive( LockTracer.NONE, ResourceTypes.LABEL, descriptor.getLabelId() );
order.verify( txState ).constraintDoAdd( ConstraintDescriptorFactory.uniqueForSchema( descriptor ), 42L );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldFindPolicyDefaults()
File privateKeyFromConfig = config.get( policyConfig.private_key );
File publicCertificateFromConfig = config.get( policyConfig.public_certificate );
File trustedDirFromConfig = config.get( policyConfig.trusted_dir );
File revokedDirFromConfig = config.get( policyConfig.revoked_dir );
String privateKeyPassword = config.get( policyConfig.private_key_password );
boolean allowKeyGeneration = config.get( policyConfig.allow_key_generation );
boolean trustAll = config.get( policyConfig.trust_all );
List<String> tlsVersions = config.get( policyConfig.tls_versions );
List<String> ciphers = config.get( policyConfig.ciphers );
ClientAuth clientAuth = config.get( policyConfig.client_auth );
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldFindThirdPartyJaxRsPackages() throws IOException
{
// given
File file = ServerTestUtils.createTempConfigFile( folder.getRoot() );
try ( BufferedWriter out = new BufferedWriter( new FileWriter( file, true ) ) )
{
out.write( ServerSettings.third_party_packages.name() );
out.write( "=" );
out.write( "com.foo.bar=\"mount/point/foo\"," );
out.write( "com.foo.baz=\"/bar\"," );
out.write( "com.foo.foobarbaz=\"/\"" );
out.write( System.lineSeparator() );
}
// when
Config config = Config.fromFile( file ).withHome( folder.getRoot() ).build();
// then
List<ThirdPartyJaxRsPackage> thirdpartyJaxRsPackages = config.get( ServerSettings.third_party_packages );
assertNotNull( thirdpartyJaxRsPackages );
assertEquals( 3, thirdpartyJaxRsPackages.size() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void isConfiguredShouldNotReturnTrueEvenThoughDefaultValueExists()
{
Config config = Config();
assertFalse( config.isConfigured( MySettingsWithDefaults.hello ) );
assertEquals( "Hello, World!", config.get( MySettingsWithDefaults.hello ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldUseWorkingDirForHomeDirIfUnspecified()
{
// given
File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build();
// when
Config testConf = Config.fromFile( configFile ).build();
// then
assertEquals( new File( System.getProperty("user.dir") ),
testConf.get( GraphDatabaseSettings.neo4j_home ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void augmentAnotherConfig()
{
Config config = Config();
config.augment( MySettingsWithDefaults.hello, "Hi" );
Config anotherConfig = Config();
anotherConfig.augment( stringMap( MySettingsWithDefaults.boolSetting.name(),
Settings.FALSE, MySettingsWithDefaults.hello.name(), "Bye" ) );
config.augment( anotherConfig );
assertThat( config.get( MySettingsWithDefaults.boolSetting ), equalTo( false ) );
assertThat( config.get( MySettingsWithDefaults.hello ), equalTo( "Bye" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeDisabledByConfigurationProperty()
{
assertFalse( configuration.with( udc_enabled, falseVariation )
.withSystemProperty( udc_enabled.name(), DEFAULT )
.withSystemProperty( UDC_DISABLE, DEFAULT )
.config( settingsClasses ).get( udc_enabled ) );
assertFalse( Config.defaults( singletonMap( udc_enabled.name(), "false" ) ).get( udc_enabled ) );
}
内容来源于网络,如有侵权,请联系作者删除!