當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigValueFactory類代碼示例

本文整理匯總了Java中com.typesafe.config.ConfigValueFactory的典型用法代碼示例。如果您正苦於以下問題:Java ConfigValueFactory類的具體用法?Java ConfigValueFactory怎麽用?Java ConfigValueFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConfigValueFactory類屬於com.typesafe.config包,在下文中一共展示了ConfigValueFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: helper_shouldPutVersion_afterDatabaseReset

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
public void helper_shouldPutVersion_afterDatabaseReset() throws IOException {
    Config config = ConfigFactory.empty()
            .withValue("database.reset", ConfigValueFactory.fromAnyRef(true));

    SPO systemProperties = new SPO(config);
    systemProperties.setDataBaseDir(databaseDir);
    systemProperties.setDatabaseVersion(33);
    final File testFile = createFile();

    assertTrue(testFile.exists());
    resetHelper.process(systemProperties);
    assertEquals(new Integer(33), resetHelper.getDatabaseVersion(versionFile));

    assertFalse(testFile.exists()); // reset should have cleared file
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:17,代碼來源:InitializerTest.java

示例2: withConfig

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
private SystemProperties withConfig(int databaseVersion, Initializer.DatabaseVersionHandler.Behavior behavior) {
    Config config = ConfigFactory.empty()
            // reset is true for tests
            .withValue("database.reset", ConfigValueFactory.fromAnyRef(false));

    if (behavior != null) {
        config = config.withValue("database.incompatibleDatabaseBehavior",
                ConfigValueFactory.fromAnyRef(behavior.toString().toLowerCase()));
    }


    SPO systemProperties = new SPO(config);
    systemProperties.setDataBaseDir(databaseDir);
    systemProperties.setDatabaseVersion(databaseVersion);
    return systemProperties;
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:17,代碼來源:InitializerTest.java

示例3: loadGenesis

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
private SystemProperties loadGenesis(String genesisFile, String genesisResource) {
    Config config = ConfigFactory.empty();

    if (genesisResource != null) {
        config = config.withValue("genesis",
                ConfigValueFactory.fromAnyRef(genesisResource));
    }
    if (genesisFile != null) {
        config = config.withValue("genesisFile",
                ConfigValueFactory.fromAnyRef(genesisFile));
    }

    SystemProperties properties = new SystemProperties(config);
    properties.getGenesis();
    return properties;
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:17,代碼來源:GenesisLoadTest.java

示例4: expectedConfiguration

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
private Config expectedConfiguration() {
    return ConfigFactory.parseMap(Map.ofEntries(
            entry(GAME_NET_IP, CFG_NET_IP),
            entry(GAME_NET_PORT, CFG_NET_PORT),
            entry(GAME_NET_TIMEOUT, 2000),
            entry(GAME_NET_RETRY_COUNT, 10),
            entry(GAME_EXE_PATH, gameRoot().toString()),
            entry(GAME_EXE_BUILD, CFG_EXE_BUILD_NEW),
            entry(GAME_EXE_FILE, CFG_EXE_FILE),
            entry(GAME_EXE_DATA_VER, CFG_EXE_DATA_VER),
            entry(GAME_EXE_IS_64, true),
            entry(GAME_WINDOW_W, CFG_WINDOW_W),
            entry(GAME_WINDOW_H, CFG_WINDOW_H),
            entry(GAME_WINDOW_X, CFG_WINDOW_X),
            entry(GAME_WINDOW_Y, CFG_WINDOW_Y),
            entry(GAME_WINDOW_MODE, 0)
    )).withValue(GAME_CLI_DATA_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_EGL_PATH, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_OS_MESA_PATH, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_DATA_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_TEMP_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_VERBOSE, ConfigValueFactory.fromAnyRef(nothing()));
}
 
開發者ID:ocraft,項目名稱:ocraft-s2client,代碼行數:24,代碼來源:S2ControllerTest.java

示例5: withConfig

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
private SystemProperties withConfig(int databaseVersion, Behavior behavior) {
    Config config = ConfigFactory.empty()
            // reset is true for tests
            .withValue("database.reset", ConfigValueFactory.fromAnyRef(false));

    if (behavior != null) {
        config = config.withValue("database.incompatibleDatabaseBehavior",
                ConfigValueFactory.fromAnyRef(behavior.toString().toLowerCase()));
    }


    SPO systemProperties = new SPO(config);
    systemProperties.setDataBaseDir(databaseDir);
    systemProperties.setDatabaseVersion(databaseVersion);
    return systemProperties;
}
 
開發者ID:Aptoide,項目名稱:AppCoins-ethereumj,代碼行數:17,代碼來源:InitializerTest.java

示例6: testDefaultConnection

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
public void testDefaultConnection() throws Exception {
  // Default root from sabot-module.conf
  assertNull(zooKeeperServer.getZKClient().exists("/dremio/test-path", false));

  final SabotConfig config = DEFAULT_SABOT_CONFIG
      .withValue(ZK_ROOT, ConfigValueFactory.fromAnyRef("dremio/test-path"))
      .withValue(CLUSTER_ID, ConfigValueFactory.fromAnyRef("test-cluster-id"));

  try(ZKClusterClient client = new ZKClusterClient(config, new Provider<Integer>() {
    @Override
    public Integer get() {
      return zooKeeperServer.getPort();
    }
  })) {
    client.start();
    ZKServiceSet serviceSet = client.newServiceSet("coordinator");
    serviceSet.register(NodeEndpoint.newBuilder().setAddress("foo").build());


    Stat stat = zooKeeperServer.getZKClient().exists("/dremio/test-path/test-cluster-id/coordinator", false);
    assertNotNull(stat);
    assertEquals(1, stat.getNumChildren());
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:26,代碼來源:TestZKClusterClient.java

示例7: applyLegacySystemProperties

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
/**
 * Remove this once all scripts stop referencing these old properties.
 */
@Deprecated
private static Config applyLegacySystemProperties(Config config){
  // legacy stuff for now.
  config = setSystemProperty(config, "dremd.write", LOCAL_WRITE_PATH_STRING);
  config = setSystemProperty(config, "dremio_autoPort", DEBUG_AUTOPORT_BOOL);
  config = setSystemProperty(config, "dremd.master", MASTER_NODE_STRING);
  config = setSystemProperty(config, "dremd.masterPort", MASTER_PORT_INT);
  config = setSystemProperty(config, "dac_prepopulate", DEBUG_PREPOPULATE_BOOL);
  config = setSystemProperty(config, "dremio_allowTestApis", DEBUG_ALLOW_TEST_APIS_BOOL);
  config = setSystemProperty(config, "dremd.localPort", SERVER_PORT_INT);
  config = setSystemProperty(config, "dremd.httpPort", WEB_PORT_INT);

  if("LOCAL".equalsIgnoreCase(System.getProperty("dremd.mode"))){
    config = config.withValue(DEBUG_SINGLE_NODE_BOOL,  ConfigValueFactory.fromAnyRef(true));
    logger.info("Applying provided leagcy system property to config: -Ddremd.mode=LOCAL");
  }

  return config;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:23,代碼來源:DremioConfig.java

示例8: applySystemProperties

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
private static Config applySystemProperties(Config config, Config reference){
  for (Entry<String, ConfigValue> entry : reference.entrySet()) {
    String property = System.getProperty(entry.getKey());
    if (property != null && !property.isEmpty()) {
      // hack to deal with array of strings
      if (property.startsWith("[") && property.endsWith("]")) {
        property = property.substring(1, property.length()-1);
        if (property.trim().isEmpty()) {
          continue;
        }
        String[] strings = property.split(",");
        if (strings != null && strings.length > 0) {
          List<String> listStrings = new ArrayList<>();
          for (String str : strings) {
            listStrings.add(str.trim());
          }
          config = config.withValue(entry.getKey(), ConfigValueFactory.fromAnyRef(listStrings));
        }
      } else {
        config = config.withValue(entry.getKey(), ConfigValueFactory.fromAnyRef(property));
      }
      logger.info("Applying provided system property to config: -D{}={}", entry.getKey(), property);
    }
  }
  return config;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:27,代碼來源:DremioConfig.java

示例9: testHandlerReflection

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
public void testHandlerReflection() {
    Config config =
            ConfigFactory.load().withValue("bag.30", ConfigValueFactory.fromAnyRef(BagForTest.class.getName()));
    BaggageHandlerRegistry registry = BaggageHandlerRegistry.create(config);

    assertEquals(1, registry.registrations.keys.length);
    assertEquals(1, registry.registrations.handlers.length);
    assertEquals(BagKey.indexed(30), registry.registrations.keys[0]);
    assertEquals(handler, registry.registrations.handlers[0]);

    BaggageHandlerForTest handler2 = new BaggageHandlerForTest();
    registry.doAdd(BagKey.indexed(5), handler2);

    assertEquals(2, registry.registrations.keys.length);
    assertEquals(2, registry.registrations.handlers.length);
    assertEquals(BagKey.indexed(5), registry.registrations.keys[0]);
    assertEquals(handler2, registry.registrations.handlers[0]);
    assertEquals(BagKey.indexed(30), registry.registrations.keys[1]);
    assertEquals(handler, registry.registrations.handlers[1]);

}
 
開發者ID:tracingplane,項目名稱:tracingplane-java,代碼行數:23,代碼來源:TestBaggageRegistry.java

示例10: accessDeniedCreatesUserWithPassword

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
public void accessDeniedCreatesUserWithPassword() throws Exception {
    Config config = defaultConfig().withValue(PASSWORD.toString(), ConfigValueFactory.fromAnyRef("password"));
    when(dbTestStatement.getMetaData()).thenThrow(new SQLException("access denied"));
    PrepareDatabaseRunner runner = new PrepareDatabaseRunner(config);

    SwingUtilities.invokeLater(runner);
    enterSuperUser(robot.finder());

    while (! runner.complete) Thread.yield();
    if (runner.thrownException != null) runner.thrownException.printStackTrace();
    assertThat(runner.createTables).isTrue();
    assertThat(runner.thrownException).isNull();
    verify(updateProgress).accept("Creating database...");
    verifyTestDatabaseQuery();
    assertThat(superConnections).hasSize(2);
    verify(superConnections.get(0), never()).prepareStatement(anyString());
    verify(superConnections.get(0), never()).createStatement();
    verifyPreparedStatement(superConnections.get(1), "create user if not exists ? identified by ?",
            config.getString(USER.toString()), config.getString(PASSWORD.toString()));
    verify(superConnections.get(1)).createStatement();
    verifyCreateDatabase(config);
    verifyCloseConnections();
}
 
開發者ID:jonestimd,項目名稱:finances,代碼行數:25,代碼來源:MysqlDriverConnectionServiceTest.java

示例11: setupCluster

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@BeforeClass
public static void setupCluster() {
  // Create a new DrillConfig which has user authentication enabled and authenticator set to
  // UserAuthenticatorTestImpl.
  final Properties props = cloneDefaultTestConfigProperties();
  final DrillConfig newConfig = new DrillConfig(DrillConfig.create(props)
          .withValue(ExecConstants.USER_AUTHENTICATION_ENABLED,
              ConfigValueFactory.fromAnyRef("true"))
          .withValue(ExecConstants.USER_AUTHENTICATOR_IMPL,
              ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)),
      false);

  final Properties connectionProps = new Properties();
  connectionProps.setProperty(DrillProperties.USER, "anonymous");
  connectionProps.setProperty(DrillProperties.PASSWORD, "anything works!");
  updateTestCluster(3, newConfig, connectionProps);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:18,代碼來源:TestCustomUserAuthenticator.java

示例12: testNoKeyPassword

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
// Should pass because the keystore password will be used.
public void testNoKeyPassword() throws Exception {
  DrillConfig testConfig = new DrillConfig(DrillConfig.create(sslConfig)
      .withValue(ExecConstants.SSL_KEY_PASSWORD, ConfigValueFactory.fromAnyRef("")),
      false);

  // Start an SSL enabled cluster
  boolean failureCaught = false;
  try {
    updateTestCluster(1, testConfig, initProps);
  } catch (Exception e) {
    failureCaught = true;
  }
  assertEquals(failureCaught, false);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:17,代碼來源:TestUserBitSSLServer.java

示例13: testInvalidSpnegoConfig

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
/**
 * Test invalid {@link SpnegoConfig} with missing keytab and principal
 * @throws Exception
 */
@Test
public void testInvalidSpnegoConfig() throws Exception {
  // Invalid configuration for SPNEGO
  try {
    final DrillConfig newConfig = new DrillConfig(DrillConfig.create()
        .withValue(ExecConstants.USER_AUTHENTICATION_ENABLED,
            ConfigValueFactory.fromAnyRef(true))
        .withValue(ExecConstants.AUTHENTICATION_MECHANISMS,
            ConfigValueFactory.fromIterable(Lists.newArrayList("plain")))
        .withValue(ExecConstants.USER_AUTHENTICATOR_IMPL,
            ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)),
        false);

    final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
    spnegoConfig.validateSpnegoConfig();
    fail();
  } catch (Exception ex) {
    assertTrue(ex instanceof DrillException);
  }
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:25,代碼來源:TestSpnegoConfig.java

示例14: testAcksWithSingleData

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@Test
public void testAcksWithSingleData() throws Exception {
  sourceConfiguration = sourceConfiguration.withValue("akka.remote.auto-ack",
    ConfigValueFactory.fromAnyRef("on"));
  source = new AkkaTestSource(sourceConfiguration);

  feederActorSystem.actorOf(
    Props.create(FeederActor.class, FeederActor.MessageTypes.SINGLE_DATA),
    feederActorName);

  source.open(config);
  sourceThread.start();

  while (DummySourceContext.numElementsCollected != 1) {
    Thread.sleep(5);
  }

  int noOfRetries = 1;
  while (Message.ACK_MESSAGE == null && noOfRetries <= 5) {
    Thread.sleep(5);
    noOfRetries++;
  }
  Assert.assertEquals("ack", Message.ACK_MESSAGE);
}
 
開發者ID:apache,項目名稱:bahir-flink,代碼行數:25,代碼來源:AkkaSourceTest.java

示例15: codahaleMetricsEngine_is_configured_with_jvm_metrics_on_or_off_based_on_property

import com.typesafe.config.ConfigValueFactory; //導入依賴的package包/類
@DataProvider(value = {
    "true",
    "false"
})
@Test
public void codahaleMetricsEngine_is_configured_with_jvm_metrics_on_or_off_based_on_property(boolean reportJvmMetrics) {
    // given
    configForTesting = generateAppConfigWithMetricsEnabledOrDisabled(true, true, false)
        .withValue("metrics.reportJvmMetrics", ConfigValueFactory.fromAnyRef(reportJvmMetrics));
    appGuiceModule = new AppGuiceModule(configForTesting);
    injector = generateInjector(appGuiceModule, configForTesting);

    // when
    CodahaleMetricsEngine engine = injector.getInstance(CodahaleMetricsEngine.class);

    // then
    assertThat(Whitebox.getInternalState(engine, "jvmMetricsAdded")).isEqualTo(reportJvmMetrics);
}
 
開發者ID:Nike-Inc,項目名稱:riposte-microservice-template,代碼行數:19,代碼來源:AppGuiceModuleTest.java


注:本文中的com.typesafe.config.ConfigValueFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。