All Downloads are FREE. Search and download functionalities are using the official Maven repository.

t.jspringbot-config.1.9.source-code.libdoc.intro Maven / Gradle / Ivy

The newest version!
A test library providing keywords for accessing configuration files.

Config is a jSpringBot library that contains keywords to access values in properties file. This library if useful for creating domain based variables.

Please see the example {{Config Library}} project.

{{jspringbot-github:sample-config|Sample Project}}

= Configuration =

Configure the following to use jspringbot-config.

1. Add this artifact in maven dependency

|  
|    
|      org.jspringbot
|      jspringbot-config
|    
|  

2. Import spring-config in {{jspringbot-global.xml}}

| 

3. Add {{JSpringBotGlobal}} library in the in the test suite settings.

| *** Settings *** |
| Library | JSpringBotGlobal |

== Configuration Files ==

The configuration files are properties file with name and value pair. The configuration files are auto detected using two ways.

*1. Using {{classpath:config.properties}}*

| domain_name=resource

where:

- {{domain_name}} = is the domain name
- {{resource}} = the domain configuration file resource

*2. Using the {{classpath:config/}} directory*

All configuration files in this directory will be auto detected where the filename without the extension is the domain.

== Examples ==

*Assume we have the following properties:*

{{classpath:config/variables.properties}}

| url=http://localhost:8080/
| property1=property1 value

{{classpath:config/sample.properties}}

| property1=sample property 1 value
| property2=sample property 2 value
| timeout=5000
| amount=5.35
| is.enable.config=true

*Sample Test Usage:*

| `Select Config Domain` | variable                      |                       |
| ${url}=                | `Get Config Property`         | url                   |
| ${property1}=          | `Get Config Property`         | property1             |
| `Select Config Domain` | sample                        |                       |
| ${sample1}=            | `Get Config Property`         | property1             |
| ${sample2}=            | `Get Config Property`         | property2             |
| ${timeout}=            | `Get Config Long Property`    | timeout               |
| ${amount}=             | `Get Config Double Property`  | amount                |
| ${configEnabled}=      | `Get Config Boolean Property` | is.enable.config      |

=>

| ${url} = "http://localhost:8080/"
| ${property1} = "property1 value"
| ${sample1} = "sample property 1 value"
| ${sample2} = "sample property 2 value"
| ${timeout} = 5000                     # integer type
| ${amount} = 5.35                      # double type
| ${configEnabled} = true               # boolean type

*Using domain object*

| ${variable}= | `Create Config Domain Object` | variable                      |
| ${sample}=   | `Create Config Domain Object` | sample                        |

=>

| ${variable.getDomain()} = "variable"
| ${variable.get('url')} = "http://localhost:8080/"
| ${variable.get('property1')} = "property1 value"
| ${sample.getDomain()} = "sample"
| ${sample.get('property1')} = "sample property 1 value"
| ${sample.get('property2')} = "sample property 2 value"
| ${sample.getInteger('timeout')} = 5000                   # integer type
| ${sample.getDouble('amount')} = 5.35                     # double type
| ${sample.getBoolean('is.enable.config')} = true          # boolean type

== Expression Support ==

{{Config Library}} has a custom jSpringBot expression language. The expression supported is as follows {{html:}}$[config{:domain}:property]{{html:}}.

Where:

- {{domain}} is optional, will use the default selection if not available.
- {{property}} is required, this is the config property.

{{html:
}} {{html:}}Important!{{html:}} The config expression is only available for jSpringBot Library keywords. {{html:
}} *Sample Test Usage:* | `Select Config Domain` | variable | | | `Evaluate Expression` | $[config:url] | # output the result to log | => | $[config:url] = "http://localhost:8080/" | $[config:property1] = "property1 value" | $[config:sample:property1] = "sample property 1 value" | $[i:config:sample:timeout] = 5000 # integer type | $[b:config:sample:is.enable.config] = true # boolean type | $[d:config:sample:amount] = 5.35 # double type




© 2015 - 2025 Weber Informatics LLC | Privacy Policy