@ThreadSafe public final class ConfigManager extends Object
LocalConfig
being used in TestNG
suites.
This supports configurations when running with parallel suites (i.e. TestNG parallel = {tests, methods, classes,
instances}) by supporting distinct local configurations for each TestNG xmltest. When reading config values without
parallel execution (parallel=false) values are effectively same as the value provided by Config
To get access to the SeLion local configuration values for the currently executing <test>.
@Test public void f(ITestContext ctx) { String name = ctx.getCurrentXmlTest().getName(); LocalConfig config = ConfigManager.getConfig(name); String Value = config.getConfigProperty(ConfigProperty.HOSTNAME); }If the current <test> name can not be determined, then defaults to the global configuration that is available via
Config.getConfigProperty(com.paypal.selion.configuration.Config.ConfigProperty)
/
Config.setConfigProperty(com.paypal.selion.configuration.Config.ConfigProperty, Object)
.Modifier and Type | Method and Description |
---|---|
static void |
addConfig(String name,
LocalConfig config)
Adds the local configuration
LocalConfig associated with name. |
static LocalConfig |
getConfig(String name)
Returns the local configuration
LocalConfig associated the provided name. |
static boolean |
isTestConfigPresent(String testName) |
static void |
printConfiguration(String testName)
A utility method that can dump the configuration for a given <test> identified with its name.
|
static boolean |
removeConfig(String name)
Remove the local configuration
LocalConfig associated supplied name. |
public static void addConfig(String name, LocalConfig config)
LocalConfig
associated with name. Over-rides any config with the same name.config
- The LocalConfig.name
- The name to associate with local config.public static LocalConfig getConfig(String name)
LocalConfig
associated the provided name. If no config with that name has
been added an IllegalArgumentException
is thrown.
Use this method for reading any "test-specific" configuration at any listener invocation.
name
- The name to search for.LocalConfig
object that either represent's the configuration object that maps to the name
given (or) a default Configuration object that apes the global configuration.public static boolean removeConfig(String name)
LocalConfig
associated supplied name.name
- The name to removetrue
if the configuration was successfully removed.public static void printConfiguration(String testName)
testName
- - The name of the test as given in the suite xml file.public static boolean isTestConfigPresent(String testName)
Copyright © 2016 PayPal Open Source. All rights reserved.