Forum Discussion

Manoj's avatar
Manoj
Contributor
18 years ago

Adding Property names on Property Transfer by groovy

Hi,

I am trying to add propety names to the property transfer step through groovy taking property names from a file . But failed.

Please help me on this. Below is the code...

// read the file
def properties = new java.util.Properties();
properties.load( new java.io.FileInputStream( "C:\\def.txt" ));
System.out.println("File was found........");
def targetStep = testRunner.testCase.getTestStepByName( "Property Transfer" );

//def names = properties.propertyNames();
def names = [];
names =  properties.propertyNames();

while( names.hasMoreElements() )
{
def name = names.nextElement();

targetStep.addProperty( name ) ;

}

7 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    shouldn't you be adding these to a "Properties" step? Property-Transfer steps don't support custom properties.. Or am I misunderstanding you?

    regards!

    /Ole
    eviware.com
  • Hi,

    I am able to add to the properties step. But could not able to add to Property transfer step.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    ok.. thats "ok".. you can't add properties to a property-transfer step. Maybe you want to add property-transfers dynamically?

    regards,

    /Ole
    eviware.com
  • Yes how can we add Property transefer dynamically?
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    you should call addTransfer ( name ) on the property-transfer step, this will create and return a new PropertyTransfer. The returned transfer then has properties for setting source/target/options, etc.. Have a look at the javadocs at http://www.soapui.org/apidocs/com/eviwa ... nsfer.html

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • For anyone else who happens upon this thread, know that SoapUI files are not saved as Java properties files - the spaces in the key names are not escaped with backslash, so you can't use:

    def properties = new java.util.Properties();
    properties.load( new java.io.FileInputStream( "C:\\def.txt" ));


    At least for SoapUI v4.6.4

    You have to write your own file parser (not hard at all).