Service Virtualization

  • 1.  class to parse magic strings

    Posted Mar 23, 2018 10:17 AM

    Hi,

     

     I am writing a java code to parse my devtest response but it contains magic strings can some one help me with jar and the class name which does this function.

     

     

    Thanks in advance.



  • 2.  Re: class to parse magic strings

    Posted Mar 23, 2018 10:25 AM

    Hi,

     

    Can you elaborate a bit more on your question.

     

    As per your what you have asked, When the service image responds, the magic strings will be replaced with the values in the response arguments.This should allow you to parse your response in which ever way you want.

     

    Regards,

    Shivakumar.



  • 3.  Re: class to parse magic strings

    Posted Mar 23, 2018 10:30 AM

    let me explain,

     

     actually when i recorded the data the response had magic string in it(recorded response). 

     

    but the response is in escape json format so when i am trying to format the json i am not able to do so due to presence of magic string. i want to do this out of my devtest in a java program. the java program will take the recorded response as input and will replace all magic string with correct value and then i will be able to format it.



  • 4.  Re: class to parse magic strings

    Broadcom Employee
    Posted Mar 23, 2018 11:09 AM

    Magic strings are replaced with appropriate values at runtime - when the VS is deployed in a VSE process. 

     

    To solve your issue - you can add the formatting logic in processResponse section of a custom data protocol handler or a scriptable data protocol handler

     

    https://docops.ca.com/devtest-solutions/10-2/en/using/using-ca-service-virtualization/using-devtest-workstation-with-ca-service-virtualization/creating-service-images/using-data-protocols/scriptable-data-protocol

     

    Within the data protocol - the testExec object of type com.itko.lisa.test.TestExec is available which has a parseInState(String containingMagicString) method - it returns a string after replacing all the magicStrings with appropriate values.



  • 5.  Re: class to parse magic strings

    Posted Mar 23, 2018 11:15 AM

    actually i am not going to deploy this on VSE. i am want to create a utility using java.i just want to know how this magic string is implemented and converted to required values. which lisa class does this. and jar in which i can find it. 



  • 6.  Re: class to parse magic strings
    Best Answer

    Posted Mar 25, 2018 04:22 PM

    I would be cautious of implementing a magic string conversion process using any DevTest classes and methods below the testExec.parseInState( <dataToParse> ) method. This is the standard wrapper that exposes the magic sting parsing logic.


    CA reserves the right to change DevTest from one release to the next. In the long term, hacking into any parsing logic below this wrapper method could be detrimental to the code you are building and the application using it.