Package com.typesafe.config

Examples of com.typesafe.config.Config


    }
  }
 
  @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


    public ExtractAvroPaths(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
      super(builder, config, parent, child, context);
      ListMultimap<String, String> stepMultiMap = ArrayListMultimap.create();
      this.flatten = getConfigs().getBoolean(config, "flatten", true);
      Config paths = getConfigs().getConfig(config, "paths");
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(paths)) {
        String fieldName = entry.getKey();       
        String path = entry.getValue().toString().trim();
        if (path.contains("//")) {
          throw new MorphlineCompilationException("No support for descendant axis available yet", config);
View Full Code Here

  private final List<ExpressionPair> excludes = new ArrayList();

  public static MetricFilter parse(Configs configs, Config config) {
    Preconditions.checkNotNull(configs);
    Preconditions.checkNotNull(config);
    Config filterConfig = configs.getConfig(config, "metricFilter", null);
    if (filterConfig == null) {
      return MetricFilter.ALL;
    } else {
      return new PatternMetricFilter(filterConfig);
    }
View Full Code Here

    }
  }
 
  private PatternMetricFilter(Config config) {
    Configs configs = new Configs();
    Config includesConfig = configs.getConfig(config, "includes", null);
    if (includesConfig == null) {
      includes.add(new ExpressionPair(new MatchAllExpression(), new MatchAllExpression()));
    } else {
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(includesConfig)) {
        includes.add(parseExpressionPair(entry.getKey(), entry.getValue().toString(), includesConfig));
      }
    }
    Config excludesConfig = configs.getConfig(config, "excludes", null);
    if (excludesConfig != null) {
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(excludesConfig)) {
        excludes.add(parseExpressionPair(entry.getKey(), entry.getValue().toString(), excludesConfig));
      }
    }
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 = new HashMap();
    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

        }
      } else {
        this.fixedSchema = null;
      }
     
      Config mappingsConfig = getConfigs().getConfig(config, "mappings", ConfigFactory.empty());
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(mappingsConfig)) {
        mappings.put(entry.getKey(), entry.getValue().toString());
      }
      validateArguments();
    }
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

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.