Service Virtualization

  • 1.  Access Property Defined In VSM From VSI

    Posted Apr 25, 2016 12:38 PM

    In my VSM, I'm using a "Read a File Step" and storing the contents into a Property Key called "MyExternalDataFile"

    ReadAFileStep.png.

     

    I'm trying to access this value in my VSI, but it appears that I can't because whenever I invoke my service, I just get back a response that says, "bad string".

    UsingProperty.png

     

     

    Is there something special I have to do in the VSI to access properties defined in the VSM?

     

    Thanks,

    Jeff



  • 2.  Re: Access Property Defined In VSM From VSI

    Posted Apr 25, 2016 01:06 PM

    Could the JSON document type defined in the VSI be causing an issue? 

    Since you are referencing a DevTest property here the content is not technically a JSON document at this point.  Also, you will not see the actual property value in the VSI - just the property key.

     

    Try changing the type to General, Text and see if the bad string goes away.

     

    If you wanted, you could add a Scripted Assertion in the VSM's VSI Selection step to dump your actual response value into the log. 

     

    import com.itko.lisa.vse.stateful.model.TransientResponse;

    import java.util.List;

    List list = testExec.getStateObject("lisa_vse_response");

    TransientResponse tr = list.get(0);

    theBody = tr.getBodyAsString();            

    // Since the body contains a value of "{{MyExternalDataFile}}", use parseInState to show the 'real' content   

    _logger.info("My Response is: \n{}", testExec.parseInState(theBody);

     

    // set the Assertion to fail if FALSE so that returning true moves on to the next step.

    return true;

     

    If you are running in VSE, the log output is written to vse.log.  If you are running the service in ITR mode, the log is output into Workstation.log (i.e., c:\users\<yourID>\lisatmp_x.x\workstation.log)



  • 3.  Re: Access Property Defined In VSM From VSI

    Posted Apr 25, 2016 01:34 PM

    Bummer.  Setting the type to General and Text doesn't get rid of the "bad string" response.

     

    So you can't access the values of a property within a VSI?  I could've sworn that I'd done this before (using {{blah}} notation to access values). 



  • 4.  Re: Access Property Defined In VSM From VSI
    Best Answer

    Posted Apr 25, 2016 01:43 PM

    Is it possible that your If Being Efficient assertion is causing a branch around the step that sets the property?


    If the property is empty that could cause you problems.





  • 5.  Re: Access Property Defined In VSM From VSI

    Posted Apr 25, 2016 04:10 PM

    That's exactly what was happening!  Can't believe I missed that. 

    I ran the VSM in ITR mode and watched it bypass my Read File Step.

    After redirecting the output of that assertion to point at my Read File Step, I was able to get back the value being stored in my property.


    Thanks J_NeSmith