Package com.typesafe.config

Examples of com.typesafe.config.Config


                // reset the cache if we start using a different loader
                cache.clear();
                currentLoader = new WeakReference<ClassLoader>(loader);
            }

            Config systemProperties = systemPropertiesAsConfig();
            if (systemProperties != currentSystemProperties) {
                cache.clear();
                currentSystemProperties = systemProperties;
            }

            Config config = cache.get(key);
            if (config == null) {
                try {
                    config = updater.call();
                } catch (RuntimeException e) {
                    throw e; // this will include ConfigException
View Full Code Here


public class ValidatorTest extends Assert {
 
  @Test
  public void testValidatorEnums() {
    Config empty = ConfigFactory.empty();
    NumRequiredMatches param;
   
    param = null;
    param = new Validator<NumRequiredMatches>().validateEnum(empty, "all", NumRequiredMatches.class);
    assertEquals(param, NumRequiredMatches.all);
View Full Code Here

    }
  }
 
  @Test
  public void testValidatorRanges() {
    Config empty = ConfigFactory.empty();
   
    new Validator<Integer>().validateRange(empty, 5, 0, 10);

    try {
      new Validator<Integer>().validateRange(empty, 5, 9, 10);
View Full Code Here

  private static final String TIKA_CONFIG_LOCATION = "tika.config";
 
  @Test
  @Ignore
  public void testBasic() {
    Config conf = ConfigFactory.load("test-application").getConfig(getClass().getPackage().getName() + ".test");
   
    assertEquals(conf.getString("foo.bar"), "1234");
    assertEquals(conf.getInt("foo.bar"), 1234);
    //assertEquals(conf.getInt("moo.bar"), 56789); // read from reference.config
   
    Config subConfig = conf.getConfig("foo");
    assertNotNull(subConfig);
    assertEquals(subConfig.getString("bar"), "1234");
   
    assertFalse(conf.hasPath("missing.foox.barx"));
    try {
      conf.getString("missing.foox.barx");
      fail("Failed to detect missing param");
View Full Code Here

  public void testParseMap() { // test access based on path
    final Map<String, String> map = Maps.newHashMap();
    map.put(TIKA_CONFIG_LOCATION, "src/test/resources/tika-config.xml");
    map.put("collection1.testcoll.solr.home", "target/test-classes/solr/collection1");
//    Config config = ConfigValueFactory.fromMap(new Context(map).getParameters()).toConfig();
    Config config = ConfigFactory.parseMap(map);
    String filePath = config.getString(TIKA_CONFIG_LOCATION);
    assertEquals(map.get(TIKA_CONFIG_LOCATION), filePath);
    Config subConfig = config.getConfig("collection1").getConfig("testcoll");
    assertEquals("target/test-classes/solr/collection1", subConfig.getString("solr.home"));
  }
View Full Code Here

    assertTimeUnitEquals(TimeUnit.NANOSECONDS, "nanosecond");
    assertTimeUnitEquals(TimeUnit.NANOSECONDS, "ns");
  }
 
  private void assertTimeUnitEquals(TimeUnit unit, String str) {
    Config config = ConfigFactory.parseString("foo : " + str);
    assertSame(unit, new Configs().getTimeUnit(config, "foo"));   
  }
View Full Code Here

    assertSame(unit, new Configs().getTimeUnit(config, "foo"));   
  }
 
  @Test
  public void testEmptyStringThrowsSyntaxError() throws Exception {
    Config config = ConfigFactory.parseString("foo : \"\"");
    try {
      new Configs().getTimeUnit(config, "foo");
      fail();
    } catch (IllegalArgumentException e) {
      ; // expected
View Full Code Here

    }
  }
 
  @Test
  public void testValidateArgumentsWithoutQuotes() throws Exception {
    Config config = ConfigFactory.parseString("{ foo : bar, see : you.there.soon }");
    Configs configs = new Configs();
    assertEquals("bar", configs.getString(config, "foo"));
    assertEquals("you.there.soon", configs.getString(config, "see"));
    configs.validateArguments(config);   
  }
View Full Code Here

    configs.validateArguments(config);   
  }
 
  @Test
  public void testValidateArgumentsWithQuotes() throws Exception {
    Config config = ConfigFactory.parseString("{ foo : bar, \"see\" : \"you.there.soon.~!@#$%^&*()_+=-\" }");
    Configs configs = new Configs();
    assertEquals("bar", configs.getString(config, "foo"));
    assertEquals("you.there.soon.~!@#$%^&*()_+=-", configs.getString(config, "see"));
    configs.validateArguments(config);   
  }
View Full Code Here

    testQuotingInHashesInternal(q + "foo~!@#$%^&*()_+=-" + q, q + "bar~!@#$%^&*()_+=-" + q);
    testQuotingInHashesInternal(q + "foo.~!@#$%^&*()_+=-" + q, q + "bar.~!@#$%^&*()_+=-" + q);
  }
 
  private void testQuotingInHashesInternal(String key, String value) throws Exception {
    Config config = ConfigFactory.parseString("{ " + key + " : " + value + "}");
    assertNameValueEquals(trimQuote(key), trimQuote(value), config);
    assertNameValueEquals2(trimQuote(key), trimQuote(value), config);
  }
View Full Code Here

TOP

Related Classes of com.typesafe.config.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.