congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ConfigReader
Code IndexAdd Tabnine to your IDE (free)

How to use
ConfigReader
in
org.chorusbdd.chorus.config

Best Java code snippets using org.chorusbdd.chorus.config.ConfigReader (Showing top 19 results out of 315)

origin: Chorus-bdd/Chorus

public String getSuiteName() {
  return configReader.isSet(ChorusConfigProperty.SUITE_NAME) ?
      concatenateName(configReader.getValues(ChorusConfigProperty.SUITE_NAME)) :
      "";
}
origin: Chorus-bdd/Chorus

private void validateProperties(Map<ConfigurationProperty, List<String>> results) throws InterpreterPropertyException {
  for ( ConfigurationProperty p : properties) {
    checkIfMandatory(results, p);
    if ( results.containsKey(p)) {
      List<String> values = results.get(p);
      checkValueCount(p, values);
      checkValues(p, values);
    }
  }
}
origin: Chorus-bdd/Chorus

private void mergeProperties(Map<ConfigSource, Map<ConfigurationProperty, List<String>>> sourceToPropertiesMap) {
  for ( ConfigSource s : propertySources) {
    Map<ConfigurationProperty, List<String>> properties = sourceToPropertiesMap.get(s);
    for ( ConfigurationProperty p : properties.keySet()) {
      List<String> valuesFromSource = properties.get(p);
      if ( valuesFromSource != null && !valuesFromSource.isEmpty()) {
        List<String> vals = getOrCreatePropertyValues(p);
        mergeValues(valuesFromSource, p, vals);
      }
    }
  }
}
origin: Chorus-bdd/Chorus

@Test
public void testBooleanSwitchUsingShortName() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus", "-d" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(c.isTrue(TestConfigProperty.DRY_RUN));
  assertTrue(c.isSet(TestConfigProperty.DRY_RUN));
}
origin: Chorus-bdd/Chorus

@Test
public void testADefaultValueDoesNotGetSetIfNoDefaultDefined() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(! c.isSet(TestConfigProperty.TAG_EXPRESSION));
}
origin: Chorus-bdd/Chorus

@Test
public void testCannotSetLessThanMinimumValues() {
  ConfigurationProperty propertyWithMinValues = new TestProperty(TestConfigProperty.HANDLER_PACKAGES) {
    public int getMinValueCount() {
      return 2;
    }
  };
  ConfigReader c = new ConfigReader(Collections.singletonList(propertyWithMinValues), new String[] { "-h", "onevalue" });
  try {
    c.readConfiguration();
  } catch (InterpreterPropertyException e) {
    assertTrue("contains At Least 2", e.getMessage().contains("At least 2 value(s) must be supplied"));
    return;
  }
  fail("Must complain when less than min vals set");
}
origin: Chorus-bdd/Chorus

@Test
public void appendPropertyMayBeSetFromMultipleSources() throws InterpreterPropertyException {
  ConfigurationProperty propertyWithMinValues = new TestProperty(TestConfigProperty.HANDLER_PACKAGES) {
    public PropertySourceMode getPropertySourceMode() {
      return PropertySourceMode.APPEND;
    }
  };
  try {
    System.setProperty("chorusHandlerPackages", "secondvalue");
    ConfigReader c = new ConfigReader(Collections.singletonList(propertyWithMinValues), new String[] { "-h", "onevalue" });
    c.readConfiguration();
    List<String> values = c.getValues(propertyWithMinValues);
    assertEquals("property value count", 2, values.size());
  } finally {
    System.clearProperty("chorusHandlerPackages");
  }
}
origin: Chorus-bdd/Chorus

/**
 * for boolean properties, is the property set true
 */
public boolean isTrue(ConfigurationProperty property) {
  return isSet(property) && propertyMap.get(property).size() == 1
    && "true".equalsIgnoreCase(propertyMap.get(property).get(0));
}
origin: Chorus-bdd/Chorus

private void setLogLevel(ConfigReader config, ChorusLogProvider chorusLogProvider) {
  String logLevel = config.getValue(ChorusConfigProperty.LOG_LEVEL);
  LogLevel l = LogLevel.getLogLevel(logLevel);
  if ( chorusLogProvider instanceof OutputWriterLogProvider) {
    //only the built in OutputFormatterLogProvider used by the interpreter supports
    //setting the log level from the interpreter configuration
    //Alternative log providers if set may use a variety of means for log level configuration
    //e.g. a log4j.xml file, at present we rely on the user to configure them as they see fit
    ((OutputWriterLogProvider) chorusLogProvider).setLogLevel(l);
  }
}
origin: Chorus-bdd/Chorus

List<FeatureToken> getFeatureList(ExecutionToken executionToken)  {
  return featureListBuilder.getFeatureList(
    executionToken,
    configReader.getValues(ChorusConfigProperty.FEATURE_PATHS),
    configReader.getValues(ChorusConfigProperty.STEPMACRO_PATHS),
    configReader.getValues(ChorusConfigProperty.TAG_EXPRESSION)
  );
}
origin: Chorus-bdd/Chorus

@Test
public void testBooleanSwitchWithValue() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus", "-dryrun", "true" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(c.isTrue(TestConfigProperty.DRY_RUN));
  assertTrue(c.isSet(TestConfigProperty.DRY_RUN));
}
origin: Chorus-bdd/Chorus

@Test
public void testCannotSetMoreThanMaxValues() {
  ConfigurationProperty propertyWithMinValues = new TestProperty(TestConfigProperty.HANDLER_PACKAGES) {
    public int getMaxValueCount() {
      return 1;
    }
  };
  ConfigReader c = new ConfigReader(Collections.singletonList(propertyWithMinValues), new String[] { "-h", "onevalue", "twovalues" });
  try {
    c.readConfiguration();
  } catch (InterpreterPropertyException e) {
    assertTrue("contains At Most 1", e.getMessage().contains("At most 1 value(s) must be supplied"));
    return;
  }
  fail("Must complain when more than max vals set");
}
origin: Chorus-bdd/Chorus

ExecutionToken createExecutionToken() {
  ExecutionToken executionToken = new ExecutionToken(getSuiteName());
  executionToken.setProfile(configReader.getValue(ChorusConfigProperty.PROFILE));
  return executionToken;
}
origin: Chorus-bdd/Chorus

private void configureSubsystems() {
  List<String> handlerClassBasePackages = configReader.getValues(ChorusConfigProperty.HANDLER_PACKAGES);
  subsystemManager.initializeSubsystems(handlerClassBasePackages);
  listenerSupport.addExecutionListeners(subsystemManager.getExecutionListeners());
}
origin: Chorus-bdd/Chorus

@Test
public void testDefaultValueGetsSetIfAvailable() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(! c.isTrue(TestConfigProperty.DRY_RUN));
  assertTrue(c.isSet(TestConfigProperty.DRY_RUN));
}
origin: Chorus-bdd/Chorus

public Chorus(String[] args) throws InterpreterPropertyException {
  //*********  To set up config and logging / output
  configReader = new ConfigReader(ChorusConfigProperty.getAll(), args);
  configReader.readConfiguration();
  outputAndLoggingConfigurer = new OutputAndLoggingConfigurer();
  configureOutputAndLogging();
  //*********  After config and logging / output is set up
  subsystemManager = new SubsystemManagerImpl();
  //add custom execution listeners before subsystem listeners
  //guarantees user listener will have their callbacks before subsystems
  addCustomExecutionListeners();
  configureSubsystems();
  //configure logging first
  interpreterBuilder = new InterpreterBuilder(listenerSupport);
  interpreter = interpreterBuilder.buildAndConfigure(configReader, subsystemManager);
  featureListBuilder = new FeatureListBuilder();
}
origin: Chorus-bdd/Chorus

@Test
public void testBooleanSwitchCanBeSetFalse() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus", "-dryrun", "false" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(! c.isTrue(TestConfigProperty.DRY_RUN));
  assertTrue(c.isSet(TestConfigProperty.DRY_RUN));
}
origin: Chorus-bdd/Chorus

@Test
public void mandatoryPropertyMustBeSet() {
  System.clearProperty(TestConfigProperty.FEATURE_PATHS.getSystemProperty());  //in case set
  String[] switches = new String[] { "-d" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  try {
    c.readConfiguration();
  } catch (InterpreterPropertyException e) {
    assertTrue(e.getMessage().contains("Mandatory property featurePaths was not set"));
    return;
  }
  fail("Must require mandatory -f property value");
}
origin: Chorus-bdd/Chorus

@Test
public void testBooleanSwitchWithoutValue() throws InterpreterPropertyException {
  String[] switches = new String[] { "-f", "./features", "-h", "org.chorusbdd.chorus", "-dryrun" };
  ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches);
  c.readConfiguration();
  assertTrue(c.isTrue(TestConfigProperty.DRY_RUN));
  assertTrue(c.isSet(TestConfigProperty.DRY_RUN));
}
org.chorusbdd.chorus.configConfigReader

Javadoc

Created with IntelliJ IDEA. User: Nick Ebbutt Date: 12/06/12 Time: 09:33 Reads and validates configuration specified either as system properties, command line switches or defaults Takes a collection of ConfigurationProperty which define the options and possible values - in the case of Chorus itself these settings are defined in ChorusConfigurationProperty enum Configuration may be provided as switches/arguments to the process, or alternatively as System properties Failing this, any defaults will apply Where a property is set in multiple sources, behaviour will depend on the PropertySourceMode for the property Where APPEND, values from each source are combined to produce a merged list Where OVERRIDE, the source with the highest priority (the last source which provided a value) will determine the value

Most used methods

  • isSet
  • <init>
    Create a configuration using process arguments, System Properties and defaults
  • getValue
  • getValues
  • readConfiguration
  • checkIfMandatory
  • checkValueCount
  • checkValues
  • getOrCreatePropertyValues
  • isTrue
    for boolean properties, is the property set true
  • mergeProperties
  • mergeValues
  • mergeProperties,
  • mergeValues,
  • validateProperties

Popular in Java

  • Reactive rest calls using spring rest template
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • setContentView (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JButton (javax.swing)
  • JTextField (javax.swing)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now