Service Virtualization

  • 1.  JavaScript error while create a newfile using timestamp

    Posted May 23, 2018 05:47 AM

    import com.itko.lisa.test.TestEvent;
    import com.itko.util.*;
    import java.io.*;
    import java.text.SimpleDateFormat;

     

    var vDate = new Date();
    var vnumber = vDate.getTime();
    var res = vnumber/1000;


    resp = testExec.getStateValue("lisa.Web Service Response.rsp");
    testExec.setStateValue("result",resp);
    //myDate = testExec.getStateValue("lisa_vse_datechecker_time_millis_zoneformat");
    //file = testExec.getStateValue("DateVal");
    testExec.setStateValue("date",res);

    out = new java.io.BufferedWriter(new java.io.FileWriter("location"+res+".txt"));
    out.write(resp);
    out.close();

     

    When Trying to execute above script.Getting error as below

     

    | Message: Sourced file: inline evaluation of: ``import com.itko.lisa.test.TestEvent; import com.itko.util.*; import java.io.*; . . . '' : Error in method invocation: Method write( com.itko.lisa.gui.XMLResultsCache ) not found in class'java.io.BufferedWriter'
    ----------------------------------------------------------------------------
    | Trapped Exception: Sourced file: inline evaluation of: ``import com.itko.lisa.test.TestEvent; import com.itko.util.*; import java.io.*; . . . '' : Error in method invocation: Method write( com.itko.lisa.gui.XMLResultsCache ) not found in class'java.io.BufferedWriter'
    | Trapped Message: Sourced file: inline evaluation of: ``import com.itko.lisa.test.TestEvent; import com.itko.util.*; import java.io.*; . . . '' : Error in method invocation: Method write( com.itko.lisa.gui.XMLResultsCache ) not found in class'java.io.BufferedWriter' : at Line: 18 : in file: inline evaluation of: ``import com.itko.lisa.test.TestEvent; import com.itko.util.*; import java.io.*; . . . '' : out .write ( resp )



  • 2.  Re: JavaScript error while create a newfile using timestamp

    Broadcom Employee
    Posted May 23, 2018 06:02 AM

    The error suggests there's a problem with what you're trying to write. You appear to have set the whole response object (an XMLResponseCache) to the variable "resp". This object would include multiple responses, metadata, think times, response body, etc.

     

    Try writing some static text to the file, and see what error you get then.

     

    What are you trying to write to the file?