How to use LocalConfig method of com.paypal.selion.configuration.LocalConfig class

Best SeLion code snippet using com.paypal.selion.configuration.LocalConfig.LocalConfig

Source:ConfigManager.java Github

copy

Full Screen

...19import net.jcip.annotations.ThreadSafe;20import org.apache.commons.lang.StringUtils;21import com.paypal.selion.logger.SeLionLogger;22/**23 * This class supports configuration operations on SeLion local configurations {@link LocalConfig} being used in TestNG24 * suites.25 * 26 * This supports configurations when running with parallel suites (i.e. TestNG parallel = {tests, methods, classes,27 * instances}) by supporting distinct local configurations for each TestNG xmltest. When reading config values without28 * parallel execution (parallel=false) values are effectively same as the value provided by {@link Config}29 * 30 * To get access to the SeLion local configuration values for the currently executing &lt;test&gt;.31 * 32 * <pre>33 * &#064;Test34 * public void f(ITestContext ctx) {35 * String name = ctx.getCurrentXmlTest().getName();36 * LocalConfig config = ConfigManager.getConfig(name);37 * String Value = config.getConfigProperty(ConfigProperty.HOSTNAME);38 * }39 * </pre>40 * 41 * If the current &lt;test&gt; name can not be determined, then defaults to the global configuration that is available42 * via {@link Config#getConfigProperty(com.paypal.selion.configuration.Config.ConfigProperty)}/43 * {@link Config#setConfigProperty(com.paypal.selion.configuration.Config.ConfigProperty, Object)}.44 * 45 */46@ThreadSafe47public final class ConfigManager {48 // Map for each TestNG test name -> local SeLion config associated with <test>49 private static Map<String, LocalConfig> configsMap = new ConcurrentHashMap<String, LocalConfig>();50 private ConfigManager() {51 // Utility class. So hide the constructor52 }53 /**54 * Adds the local configuration {@link LocalConfig} associated with name. Over-rides any config with the same name.55 * 56 * @param config57 * The LocalConfig.58 * @param name59 * The name to associate with local config.60 */61 public static synchronized void addConfig(String name, LocalConfig config) {62 SeLionLogger.getLogger().entering(new Object[] { name, config });63 checkArgument(StringUtils.isNotBlank(name),64 "A testname for which configuration is being added cannot be null (or) empty.");65 checkArgument(config != null, "A configuration object cannot be null.");66 if (configsMap.containsKey(name)) {67 String message = "Overwriting an already existing configuration";68 SeLionLogger.getLogger().warning(message);69 }70 configsMap.put(name, config);71 SeLionLogger.getLogger().exiting();72 }73 /**74 * Returns the local configuration {@link LocalConfig} associated the provided name. If no config with that name has75 * been added an {@link IllegalArgumentException} is thrown.76 * 77 * <br>78 * 79 * <pre>80 * 81 * <b><i>Use this method for reading any "test-specific" configuration at any listener invocation.</b></i>82 * 83 * </pre>84 * 85 * @param name86 * The name to search for.87 * @return - A {@link LocalConfig} object that either represent's the configuration object that maps to the name88 * given (or) a default Configuration object that apes the global configuration.89 */90 public static synchronized LocalConfig getConfig(String name) {91 SeLionLogger.getLogger().entering(name);92 checkArgument(StringUtils.isNotBlank(name),93 "The test name for which configuration is being retrieved cannot be null (or) empty.");94 // if no local config added? I.e reading from a TestNG listener (before AddConfig) or listeners disabled?95 LocalConfig localConfiguration = configsMap.get(name);96 if (localConfiguration == null) {97 throw new IllegalArgumentException(98 "A local configuration with specified name was not found. Please double check the <test> name and retry.");99 }100 SeLionLogger.getLogger().exiting(localConfiguration);101 return localConfiguration;102 }103 /**104 * Remove the local configuration {@link LocalConfig} associated supplied name.105 * 106 * @param name107 * The name to remove108 * @return - <code>true</code> if the configuration was successfully removed.109 */110 public static synchronized boolean removeConfig(String name) {111 checkArgument(StringUtils.isNotBlank(name),112 "The test name for which configuration is being retrieved cannot be null (or) empty.");113 return configsMap.remove(name) != null ? true : false;114 }115 /**116 * A utility method that can dump the configuration for a given &lt;test&gt; identified with its name.117 * 118 * @param testName119 * - The name of the test as given in the suite xml file.120 */121 public static synchronized void printConfiguration(String testName) {122 LocalConfig currentConfig = getConfig(testName);123 currentConfig.printConfigValues(testName);124 }125 public static synchronized boolean isTestConfigPresent(String testName) {126 return configsMap.containsKey(testName);127 }128}...

Full Screen

Full Screen

LocalConfig

Using AI Code Generation

copy

Full Screen

1LocalConfig localConfig = LocalConfig.getInstance();2localConfig.addConfigProperty("foo", "bar");3localConfig.addConfigProperty("foo1", "bar1");4localConfig.addConfigProperty("foo2", "bar2");5localConfig.addConfigProperty("foo3", "bar3");6localConfig.addConfigProperty("foo4", "bar4");7localConfig.addConfigProperty("foo5", "bar5");8localConfig.addConfigProperty("foo6", "bar6");9localConfig.addConfigProperty("foo7", "bar7");10localConfig.addConfigProperty("foo8", "bar8");11localConfig.addConfigProperty("foo9", "bar9");12localConfig.addConfigProperty("foo10", "bar10");13Config config = Config.getConfig();14config.addConfigProperty("foo", "bar");15config.addConfigProperty("foo1", "bar1");16config.addConfigProperty("foo2", "bar2");17config.addConfigProperty("foo3", "bar3");18config.addConfigProperty("foo4", "bar4");19config.addConfigProperty("foo5", "bar5");20config.addConfigProperty("foo6", "bar6");21config.addConfigProperty("foo7", "bar7");22config.addConfigProperty("foo8", "bar8");23config.addConfigProperty("foo9", "bar9");24config.addConfigProperty("foo10", "bar10");25Config config = Config.getConfig();26config.addConfigProperty("foo", "bar");27config.addConfigProperty("foo1", "bar1");28config.addConfigProperty("foo2", "bar2");29config.addConfigProperty("foo3", "bar3");30config.addConfigProperty("foo4", "bar4");31config.addConfigProperty("foo5", "bar5");32config.addConfigProperty("foo6", "bar6");33config.addConfigProperty("foo7", "bar7");34config.addConfigProperty("foo8", "bar8");35config.addConfigProperty("foo9", "bar9");36config.addConfigProperty("foo10", "bar10");37Config config = Config.getConfig();38config.addConfigProperty("foo", "bar");39config.addConfigProperty("foo1", "bar1");

Full Screen

Full Screen

LocalConfig

Using AI Code Generation

copy

Full Screen

1LocalConfig lc = new LocalConfig();2lc.setProperty("test", "Test");3lc.setProperty("test2", "Test2");4lc.setProperty("test3", "Test3");5lc.setProperty("test4", "Test4");6lc.setProperty("test5", "Test5");7lc.setProperty("test6", "Test6");8lc.setProperty("test7", "Test7");9lc.setProperty("test8", "Test8");10lc.setProperty("test9", "Test9");11lc.setProperty("test10", "Test10");12lc.setProperty("test11", "Test11");13lc.setProperty("test12", "Test12");14lc.setProperty("test13", "Test13");15lc.setProperty("test14", "Test14");16lc.setProperty("test15", "Test15");17lc.setProperty("test16", "Test16");18lc.setProperty("test17", "Test17");19lc.setProperty("test18", "Test18");20lc.setProperty("test19", "Test19");21lc.setProperty("test20", "Test20");22lc.setProperty("test21", "Test21");23lc.setProperty("test22", "Test22");24lc.setProperty("test23", "Test23");25lc.setProperty("test24", "Test24");26lc.setProperty("test25", "Test25");27lc.setProperty("test26", "Test26");28lc.setProperty("test27", "Test27");29lc.setProperty("test28", "Test28");30lc.setProperty("test29", "Test29");31lc.setProperty("test30", "Test30");32lc.setProperty("test31", "Test31");33lc.setProperty("test32", "Test32");34lc.setProperty("test33", "Test33");35lc.setProperty("test34", "Test34");36lc.setProperty("test35", "Test35");37lc.setProperty("test36", "Test36");38lc.setProperty("test37", "Test37");39lc.setProperty("test38", "Test38");40lc.setProperty("test39", "Test39");41lc.setProperty("test40", "Test40");42lc.setProperty("test41", "Test41");43lc.setProperty("test42", "Test42");44lc.setProperty("test43", "Test43");45lc.setProperty("test44", "Test44");46lc.setProperty("test45", "Test45");47lc.setProperty("test46", "Test46");48lc.setProperty("test47", "Test47");49lc.setProperty("test48", "Test48");50lc.setProperty("test49", "Test49");

Full Screen

Full Screen

LocalConfig

Using AI Code Generation

copy

Full Screen

1LocalConfig config = LocalConfig.getInstance();2String value = config.getConfigProperty("key");3LocalConfig config = LocalConfig.getInstance();4String value = config.getConfigProperty("key");5LocalConfig config = LocalConfig.getInstance();6String value = config.getConfigProperty("key");7LocalConfig config = LocalConfig.getInstance();8String value = config.getConfigProperty("key");9LocalConfig config = LocalConfig.getInstance();10String value = config.getConfigProperty("key");11LocalConfig config = LocalConfig.getInstance();12String value = config.getConfigProperty("key");13LocalConfig config = LocalConfig.getInstance();14String value = config.getConfigProperty("key");15LocalConfig config = LocalConfig.getInstance();16String value = config.getConfigProperty("key");17LocalConfig config = LocalConfig.getInstance();18String value = config.getConfigProperty("key");19LocalConfig config = LocalConfig.getInstance();20String value = config.getConfigProperty("key");21LocalConfig config = LocalConfig.getInstance();22String value = config.getConfigProperty("key");23LocalConfig config = LocalConfig.getInstance();24String value = config.getConfigProperty("key");

Full Screen

Full Screen

LocalConfig

Using AI Code Generation

copy

Full Screen

1System.out.println(LocalConfig.getConfigProperty("testKey"));2System.out.println(LocalConfig.getConfigProperty("testKey"));3System.out.println(LocalConfig.getConfigProperty("testKey"));4System.out.println(LocalConfig.getConfigProperty("testKey"));5System.out.println(LocalConfig.getConfigProperty("testKey"));6System.out.println(LocalConfig.getConfigProperty("testKey"));7System.out.println(LocalConfig.getConfigProperty("testKey"));8System.out.println(LocalConfig.getConfigProperty("testKey"));9System.out.println(LocalConfig.getConfigProperty("testKey"));

Full Screen

Full Screen

LocalConfig

Using AI Code Generation

copy

Full Screen

1LocalConfig lc = LocalConfig.getInstance();2String loginPageTitle = lc.getConfigProperty("loginPageTitle");3String loginPageURL = lc.getConfigProperty("loginPageURL");4String loginPageUserName = lc.getConfigProperty("loginPageUserName");5String loginPagePassword = lc.getConfigProperty("loginPagePassword");6String loginPageSubmitButton = lc.getConfigProperty("loginPageSubmitButton");7String homePageTitle = lc.getConfigProperty("homePageTitle");8String homePageURL = lc.getConfigProperty("homePageURL");9String homePageLogoutButton = lc.getConfigProperty("homePageLogoutButton");10String loginPageTitle = LocalConfig.getInstance().getConfigProperty("loginPageTitle");11String loginPageURL = LocalConfig.getInstance().getConfigProperty("loginPageURL");12String loginPageUserName = LocalConfig.getInstance().getConfigProperty("loginPageUserName");13String loginPagePassword = LocalConfig.getInstance().getConfigProperty("loginPagePassword");14String loginPageSubmitButton = LocalConfig.getInstance().getConfigProperty("loginPageSubmitButton");15String homePageTitle = LocalConfig.getInstance().getConfigProperty("homePageTitle");16String homePageURL = LocalConfig.getInstance().getConfigProperty("homePageURL");17String homePageLogoutButton = LocalConfig.getInstance().getConfigProperty("homePageLogoutButton");18String loginPageTitle = LocalConfig.getInstance().getConfigProperty("loginPageTitle");19String loginPageURL = LocalConfig.getInstance().getConfigProperty("loginPageURL");20String loginPageUserName = LocalConfig.getInstance().getConfigProperty("loginPageUserName");21String loginPagePassword = LocalConfig.getInstance().getConfigProperty("loginPagePassword");22String loginPageSubmitButton = LocalConfig.getInstance().getConfigProperty("loginPageSubmitButton");23String homePageTitle = LocalConfig.getInstance().getConfigProperty("homePageTitle");24String homePageURL = LocalConfig.getInstance().getConfigProperty("homePageURL");25String homePageLogoutButton = LocalConfig.getInstance().getConfigProperty("homePageLogoutButton");26String loginPageTitle = LocalConfig.getInstance().getConfigProperty("loginPageTitle");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful