Dashboard > Documentation > Documentation > Property Placeholders
  Documentation Log In | Sign Up   View a printable version of the current page.  
  Property Placeholders
Added by Adam Skogman, last edited by Adam Skogman on Feb 05, 2006  (view change)
Labels: 
(None)

How they Work

In the test data in the Excel sheet, you can write these nice property placeholders: *${foo.bar}. They are very convenient for making test data dependent on the current user (use ${user.name} or for placing the current time and date in your test case.

TODO: Image, Excel sheet with property placeholder

They work in much the same way as the PropertyPlaceholderConfigurer in the Spring Framework. DDSteps will replace these placeholders by...

  1. Looking for a system property with that key. (Java has a lot of default system proerpties, like ${user.name}).
  2. Looking up the key in the file ddsteps-placeholders.properties.

For example:
If you have an excel file with:

text
Some *${foo.bar} here.

And the system properties contain:

foo.bar=fruit

And the ddsteps-placeholders.properties file contains:

foo.bar=meat

Then the text property in your test class will be injected with the String "Some fruit here", since the system properties takes precedence.

System properties

The system properties are checked first, so if you want to override something from Ant, just put it in the system properties, and that will be used first.

There are some good system properties that you may want to use:

Property Contents
user.name The user login id
user.home The user's home directory

The ddsteps-placeholders.properties file

DDSteps expects this file to be present in the root of your classpath. DDSteps uses the Java classloader to load it, so just put it in the default package (typically directly in the source folder in your IDE).

The file is called ddsteps-placeholders.properties and is a standard Java properties file - that means you have to quote characters. Read the JavaDocs for java.util.Properties.

Adding support for Property Placeholders

Already included!

Support is already included when you:

  • Extend org.ddsteps.testcase.support.DDStepsExcelTestCase.
  • Get your DataLoader from:
    • org.ddsteps.data.support.DataLoaderFactory.getCachingExcelDataLoader() (DDSteps 1.1)
    • org.ddsteps.data.excel.CachingExcelDataLoader.getInstance() (DDSteps 1.0, deprecated)
    • new org.ddsteps.data.excel.CachingExcelDataLoader() (DDSteps 0.x, deprecated)
  • Get your DataSetLoader from:
    • org.ddsteps.dataset.support.DataSetLoaderFactory.getPropertyPlaceholderExcelDataSetLoader() (DDSteps 1.1)
    • org.ddsteps.dataset.support.DataSetLoaderFactory.getCachingPropertyPlaceholderExcelDataSetLoader() (DDSteps 1.1)

Add support to your DataSetLoader

Scary technical details ahead!
Property Placeholders are added to your DataSet using the DecoratingDataSetLoader.

TODO: Beef up this doc.
If you want to roll your own DataSetLoader with PropertyPlaceholder support, look at the source here:
org.ddsteps.dataset.support.DataSetLoaderFactory.getCachingPropertyPlaceholderExcelDataSetLoader()

See also: [DataSetLoaders].

Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2 Build:#512 Apr 26, 2006) - Bug/feature request - Contact Administrators