Forum Discussion

DisTreSs's avatar
DisTreSs
Occasional Contributor
16 years ago

n00b question: how to enter a dynamic date?

Sorry for the n00bness but I've tried to find a solution to this problem and was unable to come up with anything...

What I would like to do is to have a date (systemdate+15days for example) entered automatically in my SOAP-request without having to use an excel or other file as the basis for this date.
Since I have no knowledge of groovy scripting, I was wondering how I would be able to accomplish this.

I tried using an excel-file as datasource with =TODAY()+15 in one cell, but when SOAPUI calls this file, it does not first update the value of the cell containing the formula... this means SOAPUI can only use the new value (13th of february assuming that I opened the file today, 29th of january) once I opened and saved the excel file and this is not something I want to do every day

Thanks in advance for your assistance! 

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    Since it seems you are using soapUI Pro I suggest you use the new DataGen teststep; add it to your testcase and add a script-property to it with the following configuration;

    def ldf = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    Calendar c1 = Calendar.getInstance();
    c1.add(Calendar.DAY,15);

    return ldf.format( c1.time )


    Set the read-type of the property to "Read" and refer to this property from where you need to use it with property-expansion; ${nameOfDataGenTestStep#nameOfProperty}, for example

    ${DataGen#nextDate}

    if the name of the property is nextDate and the name of the DataGen teststep is DataGen

    Hope this helps!

    regards!

    /Ole
    eviware.com
  • DisTreSs's avatar
    DisTreSs
    Occasional Contributor
    Thank you very much for your help!!! Much appreciated...

    However, when I add the datagen step as described and run it, I get the following error message: No such property: DAY for class: java.util.Calendar

    Forwarding the property from the datagen step as described and performing the request obviously has the same result. The reply I get then indicates No such property: DAY for class: java.util.Calendar
  • DisTreSs's avatar
    DisTreSs
    Occasional Contributor
    Works like a charm now!!!
    Thx again, you're a life saver