Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.SubsetConfiguration$SubsetIterator


  /**
   * Include patterns should take precedence over exclude patterns
   */
  @Test public void includeShouldOverrideExclude() {
    SubsetConfiguration c = new ConfigBuilder()
        .add("p.include", "foo")
        .add("p.include.tags", "foo:f")
        .add("p.exclude", "foo")
        .add("p.exclude.tags", "foo:f").subset("p");
    shouldAccept(c, "foo");
View Full Code Here


import static org.apache.hadoop.metrics2.filter.TestPatternFilter.*;

public class TestMetricsBuilderImpl {

  @Test public void recordBuilderShouldNoOpIfFiltered() {
    SubsetConfiguration fc = new ConfigBuilder()
        .add("p.exclude", "foo").subset("p");
    MetricsBuilderImpl mb = new MetricsBuilderImpl();
    mb.setRecordFilter(newGlobFilter(fc));
    MetricsRecordBuilderImpl rb = mb.addRecord("foo");
    rb.tag("foo", "", "value").addGauge("g0", "", 1);
View Full Code Here

    assertNull("null record", rb.getRecord());
    assertEquals("no records", 0, mb.getRecords().size());
  }

  @Test public void testPerMetricFiltering() {
    SubsetConfiguration fc = new ConfigBuilder()
        .add("p.exclude", "foo").subset("p");
    MetricsBuilderImpl mb = new MetricsBuilderImpl();
    mb.setMetricFilter(newGlobFilter(fc));
    MetricsRecordBuilderImpl rb = mb.addRecord("foo");
    rb.tag("foo", "", "").addCounter("c0", "", 0).addGauge("foo", "", 1);
View Full Code Here

   * Return a subset configuration (so getParent() can be used.)
   * @param prefix  of the subset
   * @return the subset config
   */
  public SubsetConfiguration subset(String prefix) {
    return new SubsetConfiguration(config, prefix, ".");
  }
View Full Code Here

  /**
   * Filters should default to accept
   */
  @Test public void emptyConfigShouldAccept() {
    SubsetConfiguration empty = new ConfigBuilder().subset("");
    shouldAccept(empty, "anything");
    shouldAccept(empty, Arrays.asList(new MetricsTag("key", "desc", "value")));
  }
View Full Code Here

  /**
   * Filters should handle white-listing correctly
   */
  @Test public void includeOnlyShouldOnlyIncludeMatched() {
    SubsetConfiguration wl = new ConfigBuilder()
        .add("p.include", "foo")
        .add("p.include.tags", "foo:f").subset("p");
    shouldAccept(wl, "foo");
    shouldAccept(wl, Arrays.asList(new MetricsTag("bar", "", ""),
                                   new MetricsTag("foo", "", "f")));
View Full Code Here

  /**
   * Filters should handle black-listing correctly
   */
  @Test public void excludeOnlyShouldOnlyExcludeMatched() {
    SubsetConfiguration bl = new ConfigBuilder()
        .add("p.exclude", "foo")
        .add("p.exclude.tags", "foo:f").subset("p");
    shouldAccept(bl, "bar");
    shouldAccept(bl, Arrays.asList(new MetricsTag("bar", "", "")));
    shouldReject(bl, "foo");
View Full Code Here

  /**
   * Filters should accepts unmatched item when both include and
   * exclude patterns are present.
   */
  @Test public void shouldAcceptUnmatchedWhenBothAreConfigured() {
    SubsetConfiguration c = new ConfigBuilder()
        .add("p.include", "foo")
        .add("p.include.tags", "foo:f")
        .add("p.exclude", "bar")
        .add("p.exclude.tags", "bar:b").subset("p");
    shouldAccept(c, "foo");
View Full Code Here

  /**
   * Include patterns should take precedence over exclude patterns
   */
  @Test public void includeShouldOverrideExclude() {
    SubsetConfiguration c = new ConfigBuilder()
        .add("p.include", "foo")
        .add("p.include.tags", "foo:f")
        .add("p.exclude", "foo")
        .add("p.exclude.tags", "foo:f").subset("p");
    shouldAccept(c, "foo");
View Full Code Here

        // get configuration property
        Object result = getConfiguration().getProperty(name);
        if (result == null)
        {
            // otherwise attempt to create bean from configuration subset
            Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
            if (!subset.isEmpty())
            {
                result = new ConfigurationDynaBean(subset);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.SubsetConfiguration$SubsetIterator

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.