Forum Discussion

AnandKiran's avatar
AnandKiran
Frequent Contributor
16 years ago

Groovy script - instead of using Property Transfer

Hi,

Here is the scenario for which i want to use groovy script instead of using Property Transfer

1. In my test case I have three steps
a. Property_Transfer
b. Operation_Initialize_Request
c. Operation_Request

In the "Property_Transfer" step
I have the Source as "Operation_Initialize_Request" and its property is "request" &
                  Target as "Operation_Request"                 and its property is "request"

This is the actual work flow I am following to initialize my request every time I execute the testcase.

Now I want to do this using groovy, instead of using the Property Transfer Step. Can any one suggest me an idea to achieve this..

Note: For reference I have also attached my sample project.

Regards
AnandKiran.

6 Replies

  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    I Found that we can use Java API to acheieve this scenario . Can anyone please suggest me an idea on how to go about this
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi  ,

    Can you please help me to figure this out.This is what i found from one of the post

    import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer;
    import com.eviware.soapui.model.testsuite.*;
    import com.eviware.soapui.model.support.AbstractModelItem.*;
    import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfersTestStep.*;


    PropertyTransfersStepFactory propertyTransfersStepFactory = new PropertyTransfersStepFactory();
    TestStepConfig stepConfig = propertyTransfersStepFactory.createNewTestStep("Repository", "hh");
    step = testCase.addTestStep(stepConfig);


    But when i tried this i got the below error



    Fri Dec 18 05:30:11 GMT 2009:ERROR:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script48.groovy: 29: unable to resolve class PropertyTransfersStepFactory
    @ line 29, column 30.org.codehaus.groovy.syntax.SyntaxException: unable to resolve class PropertyTransfersStepFactory
    @ line 29, column 30.
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:113)
    at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:205)
    at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:215)
    at org.codehaus.groovy.control.ResolveVisitor.transformVariableExpression(ResolveVisitor.java:831)
    at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:637)
    at org.codehaus.groovy.control.ResolveVisitor.transformDeclarationExpression(ResolveVisitor.java:906)
    at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:641)
    at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:148)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:129)
    at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1021)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:52)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:73)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:80)
    at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod....................................................
  • Perhaps this will works:

    // get request property
    def request = testRunner.testCase.getTestStepByName( "Initialize" )
    def property = request.getProperty( "request" )

    // set request property
    request = testRunner.testCase.getTestStepByName( "Calcxml" )
    request.getProperty("request").setValue(property)
  • I see I had an error:

    // get request property
    def request = testRunner.testCase.getTestStepByName( "Initialize" )
    def property = request.getProperty( "request" )

    // set request property
    request = testRunner.testCase.getTestStepByName( "Calcxml" )
    request.getProperty("request").setValue(property.getValue())
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi Jeff,

    Thanks for the reply let me check and get back to you if i face any issues.

    Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hey Jeff,

    Got the solution


    // get request property
    request1  = groovyUtils.getXmlHolder("Initiallize#Request")
    def sam  = request1.xml

    // set request property
    request5 = testRunner.testCase.getTestStepByName( "Calcxml" )
    request5.getProperty("request").setValue(sam)


    It worked perfectly for me Hope this helps others too.

    Thanks alot Jeff for your idea

    Regards
    Anand.