26 September 2007 - 1.7.6 | home user-guide eclipse jbossws intellij netbeans maven 1.X/2.X PDF files forums bugs sourceforge

Home
Getting Started
User Guide

- Overview
  - Tabbed Desktop
  - License Management
  - Preferences
  - XPath Selection
  - Script Library
- Workspaces
- Projects
- Interfaces
  - Interface Viewer
- Operations
- Working with Requests
  - Form Editor
  - Overview View
  - Outline Editor
  - Message Inspectors
  - Attachments/Inline Files
- Functional Testing
  - Getting Started
  - TestSuites
  - TestCases
    - Test Requests
      - Assertions
      - Editor Wizards
    - Property Transfers
    - Conditional Gotos
    - Groovy Scripts
      - Examples
      - GroovyUtils
    - Properties Step
    - Delay Step
    - Mock Response
    - DataSource
    - DataSource Loop
  - Property Expansion
- Load Testing
  - Getting Started
  - Limit & Strategies
  - Execution
  - Assertions
  - Diagrams
  - JMeter comparison
- Mocking
  - Getting Started
  - Mock Services
  - Mock Operations
  - Mock Responses
- Usage Scenarios
  - Data-Driven Testing
  - Template-Driven Testing
  - Interactive Testing
  - Surveillance Testing
- Tool Integrations
  - Code Generation
  - WSDL Generation
  - WS-I Tools
  - Apache Tcp-Mon
- CommandLine Tools
  - TestCaseRunner
  - LoadTestRunner
  - MockServiceRunner
  - ToolRunner
- Keyboard shortcuts

IDE/Tool Plugins
Search soapUI site
Project Documentation

- About soapUI
- Project Info
- Project Reports

## Property Expansion

soapUI provides a common `${[testStepName#]propertyName[#xpath-expression]}` syntax to dynamically insert values into a number of values during processing. Currently, properties are expanded in:

- request messages
- mock response messages (from the MockRunContext see Response Scripts), testStepName is ignored.
- xpath assertions and their matching values
- xpath source/target property transfers
- contains/not-contains content assertions
- request endpoints
- custom request/mock-response http headers
- property-transfer xpath expressions
- datasource step configuration values (soapUI Pro only)
- mockresponse step response messages (soapUI Pro only)

When properties are expanded, soapUI will look for the named property as follows:

1. if the property contains the name of a testStep, query that step directly
2. in the current run/submitcontext where properties can have been set from a groovy-script
3. in all teststep properties starting from the current step backwards to the first if the "Search Properties" option has been selected in the TestCase Options dialog)

For example, the following request gets the Author property as described above, either from a preceding PropertiesStep containing the corresponding property or from the current context set by a preceding Groovy Script:

    <ns:Request>
       <ns:Author>${Properties#Author}</ns:Author>
    </ns:Request>

Since the value of the property will be set just before it is used, the actual used value will not be seen in the corresponding editors.

If the property expansion further includes an xpath expression, this will be selected from the property value, for example the above example could "extract" the author value from a preceding response with:

    <ns:Request>
       <ns:Author>${Search Request#Response#//ns1:Item[1]/n1:Author[1]/text()}</ns:Author>
    </ns:Request>

Which would first get the "Response" property of the "Search Request" step and then select the value of the first Items' first Author element. Note that the namespace prefix must match those used in the response message, otherwise the expansion will fail.

Property Transfers are a more tedious way of accomplishing the same functionality as with property-expansion. On the other hand, property transfers provide the possibility to transfer complex content between request/response messages. Also, the result of a Property Transfer is visible directly in the corrsponding request/response editors.

### Global Properties

soapUI 1.7.6 introduces rudimentary support for global properties as follows:

- Specify a global properties file at the command-line by adding a -Dsoapui.properties argument in the soapui.bat/.sh file
- Refer to properties in this file using a ${##property.name} syntax

The specified file will be read the first time a global property is referenced. If the specified property is not available or no file has been specified, the corrsponding System Property will be returned instead if available

For example, create a properties-file named "properties.txt" containing

    test.a.property=hello!

in the soapUI bin folder. Modify the java arguments in the soapUI.bat file to be

    set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -Dsoapui.properties=properties.txt

Add the following expansion to a TestRequest/Endpoint/etc..

    ${##test.a.property}

When expanded, the specified properties file will be loaded as shown in the soapUI log:

    01:20:05,234 INFO  [PropertyExpansionRequestFilter] Loaded 52 properties from [C:\workspace\core\project.properties]

This feature can be especially usefull when wanting to specify global endpoints/authentication settings, just specify the corresponding expansions in the endpoint/authentications properties and they will get expanded when used

### Nested Properties

soapUI supports both nested and recursive property-expansion (be carefull!), for example:

    test = "value"
    testexp = "${test}"

    -> "${testexp}" evaluates to "value"

    testexp = "value"
    exp = "${exp}"

    -> "${test${exp}}" evaluates to "value"

    testxml = "<test><value id="123">hello</value></test>"
    testxpath = "//value[@id=${id}]/text()"
    id = "123"

    -> "${#testxml#${testxpath}}" evaluates to "hello"

### Available Properties

The table below lists all properties available for property-expansion and property-transfers

#### TestRequest Step
Property | Description
--- | ---
Request | The configures request message
Response | The last response message (read-only)
Endpoint | The current endpoint for the request
Username | The current username for the request
Password | The current password for the request
Domain | The current domain for the request
#### Properties Step
Property | Description
<any defined property> | the properties' value
#### GroovyScript Step
Property | Description
result | the value returned by the script from its last run (read-only)
#### DataSource Step (soapUI Pro only)
Property | Description
<any defined property> | the properties' value (read-only)
#### MockResponse Step (soapUI Pro only)
Property | Description
Request | The last request message (read-only)
Response | The configured response message

Next: LoadTesting