org.neo4j.kernel.configuration.Config.fromFile()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.neo4j.kernel.configuration.Config.fromFile()方法的一些代码示例,展示了Config.fromFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.fromFile()方法的具体详情如下:
包路径:org.neo4j.kernel.configuration.Config
类名称:Config
方法名:fromFile

Config.fromFile介绍

[英]Convenient method for starting building from a file.
[中]从文件开始构建的方便方法。

代码示例

代码示例来源:origin: neo4j/neo4j

Config loadNeo4jConfig()
  {
    return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ).toFile() )
        .withHome( homeDir.toFile() )
        .withNoThrowOnFileLoadFailure()
        .withConnectorsDisabled().build();
  }
}

代码示例来源:origin: neo4j/neo4j

Config loadNeo4jConfig()
  {
    return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
        .withHome( homeDir )
        .withConnectorsDisabled()
        .withNoThrowOnFileLoadFailure()
        .build();
  }
}

代码示例来源:origin: neo4j/neo4j

private Config buildConfig( String databaseName )
{
  return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
      .withHome( homeDir )
      .withConnectorsDisabled()
      .withNoThrowOnFileLoadFailure()
      .withSetting( GraphDatabaseSettings.active_database, databaseName )
      .build();
}

代码示例来源:origin: neo4j/neo4j

private Config buildConfig( String databaseName )
{
  return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
      .withHome( homeDir )
      .withConnectorsDisabled()
      .withNoThrowOnFileLoadFailure()
      .withSetting( GraphDatabaseSettings.active_database, databaseName )
      .build();
}

代码示例来源:origin: neo4j/neo4j

private static Config loadNeo4jConfig( Path homeDir, Path configDir, String databaseName, Config additionalConfig )
{
  Config config = Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
      .withHome( homeDir )
      .withConnectorsDisabled()
      .withNoThrowOnFileLoadFailure()
      .build();
  config.augment( additionalConfig );
  config.augment( GraphDatabaseSettings.active_database, databaseName );
  return config;
}

代码示例来源:origin: neo4j/neo4j

private static Config loadNeo4jConfig( Path homeDir, Path configDir, String databaseName, Config additionalConfig )
  {
    Config config = Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
        .withHome( homeDir )
        .withConnectorsDisabled()
        .withNoThrowOnFileLoadFailure()
        .build();
    config.augment( additionalConfig );
    config.augment( GraphDatabaseSettings.active_database, databaseName );
    return config;
  }
}

代码示例来源:origin: neo4j/neo4j

@Test( expected = UncheckedIOException.class )
public void shouldThrowWhenSpecifiedConfigFileDoesNotExist()
{
  // Given
  File nonExistentConfigFile = new File( "/tmp/" + System.currentTimeMillis() );
  // When
  Config config = Config.fromFile( nonExistentConfigFile ).withHome( folder.getRoot() ).build();
  // Then
  assertNotNull( config );
}

代码示例来源:origin: neo4j/neo4j

@Test( expected = ConfigLoadIOException.class )
public void mustThrowIfConfigFileCouldNotBeFound()
{
  File confFile = testDirectory.file( "test.conf" );
  Config.fromFile( confFile ).build();
}

代码示例来源:origin: neo4j/neo4j

@Test( expected = ConfigLoadIOException.class )
public void mustThrowIfConfigFileCoutNotBeRead() throws IOException
{
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  assumeTrue( confFile.setReadable( false ) );
  Config.fromFile( confFile ).build();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldLogIfConfigFileCouldNotBeRead() throws IOException
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  assumeTrue( confFile.setReadable( false ) );
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).error( "Unable to load config file [%s]: %s", confFile, confFile + " (Permission denied)" );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldLogIfConfigFileCouldNotBeFound()
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" ); // Note: we don't create the file.
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).warn( "Config file [%s] does not exist.", confFile );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldWorkFineWhenSpecifiedConfigFileDoesNotExist()
{
  // Given
  File nonExistentConfigFile = new File( "/tmp/" + System.currentTimeMillis() );
  // When
  Config config = Config.fromFile( nonExistentConfigFile ).withHome( folder.getRoot() ).withNoThrowOnFileLoadFailure().build();
  // Then
  assertNotNull( config );
}

代码示例来源: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 shouldDefaultToCorrectValueForAuthStoreLocation()
{
  File configFile = ConfigFileBuilder
      .builder( folder.getRoot() )
      .withoutSetting( GraphDatabaseSettings.data_directory )
      .build();
  Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build();
  assertThat( config.get( DatabaseManagementSystemSettings.auth_store_directory ),
      is( new File( folder.getRoot(), "data/dbms" ).getAbsoluteFile() ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldSetAValueForAuthStoreLocation()
{
  File configFile = ConfigFileBuilder.builder( folder.getRoot() )
      .withSetting( GraphDatabaseSettings.data_directory, "the-data-dir" )
      .build();
  Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build();
  assertThat( config.get( DatabaseManagementSystemSettings.auth_store_directory ),
      is( new File( folder.getRoot(), "the-data-dir/dbms" ).getAbsoluteFile() ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
  public void shouldNotOverwriteAuthStoreLocationIfProvided()
  {
    File configFile = ConfigFileBuilder.builder( folder.getRoot() )
        .withSetting( GraphDatabaseSettings.data_directory, "the-data-dir" )
        .withSetting( GraphDatabaseSettings.auth_store, "foo/bar/auth" )
        .build();
    Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build();

    assertThat( config.get( GraphDatabaseSettings.auth_store ),
        is( new File( folder.getRoot(), "foo/bar/auth" ).getAbsoluteFile() ) );
  }
}

代码示例来源:origin: neo4j/neo4j

public CommunityNeoServer build() throws IOException
{
  if ( dataDir == null && persistent )
  {
    throw new IllegalStateException( "Must specify path" );
  }
  final File configFile = buildBefore();
  Log log = logProvider.getLog( getClass() );
  Config config = Config.fromFile( configFile ).withServerDefaults().build();
  config.setLogger( log );
  return build( configFile, config, GraphDatabaseDependencies.newDependencies().userLogProvider( logProvider )
      .monitors( new Monitors() ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldProvideAConfiguration()
{
  // given
  File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build();
  // when
  Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build();
  // then
  assertNotNull( config );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldUseSpecifiedHomeDir()
{
  // given
  File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build();
  // when
  Config testConf = Config.fromFile( configFile ).withHome( folder.getRoot() ).build();
  // then
  assertEquals( folder.getRoot(), testConf.get( GraphDatabaseSettings.neo4j_home ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void loadOfflineConfigAddDisabledBoltConnector()
{
  // given
  File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build();
  // when
  Config testConf = Config.fromFile( configFile ).withHome( folder.getRoot() ).withConnectorsDisabled().build();
  // then
  assertNotNull( testConf );
  assertEquals( false, testConf.get( new BoltConnector().enabled ) );
}

相关文章