Greetings, sebb!

s> On 27/11/2007, Dmitry Kudrenko <[EMAIL PROTECTED]> wrote:
>> >> I need to implement the following functions for my testplan:
>> >> 1. long __timestamp()
>> >>   returns new Date().getTime()
>>
>> s> ${__time()}
>> Oh, sorry. I thought it returns only string representation of time
>> using specified format. I omitted corresponding notes in the
>> documentation.
>> >> 2. long __timeDuration(String variableName)
>> >>   returns new Date().getTime() - variables.get(variableName)
>>
>> s> ${__intSum(${__time()},-${variableName})}
>> Thank you. I am always forgot about such this sort of notation like
>> -${variableName}
BTW, intSum is working with int, but __time() returns long. And seems
example you send me is not working because the following conversion is
used:

Integer.parseInt(((CompoundVariable) values[i]).execute());

>> >> 3. boolean __isTimeoutExpaired(String variableName, long timeout)
>> >>   returns true if __timeduration for variableName more than specified
>> >>   timeout.
>>
>> s> ${__javaScript(${variableName} > timeout)}
>> Yes, you are right, but I don't like to use __javaScript at all. When
>> I replaced my __javaScripts calculations to __BeanShell my test plan
>> works in several times faster. Maybe it is so only for calculations but
>> not for comparing operations.

s> I'd not noticed that javaScript is slower than BeanShell.
s> Perhaps it is the startup time - the BeanShell interpreter is re-used
s> by the function; I think the JS interpreter is created afresh each
s> time. Not sure if it is possible to change that.
All threads in my test plan are blocked long time with javaScript.execute(). And
test works faster after every replacement javaScript to BeanShell or
custom functions. Not ready to post it as bug but have this situation
for me.

s> Forgot to mention you can also use __jexl().
Yes, thank you. I remember about it, maybe it is faster but
unfortunately I didn't try it yet. But I will. Thank you.

Seems our conversation should be continued on the user's branch. :)

s> Might be faster than __javaScript() and you don't have to download any jars.
s> But I think it is also recreated each time.

>> In any case I agree with you it is not necessary function without
>> previous. Thank you.
>>
>> >> It is useful for me to use them in operations with timeouts.
>> >> E.g.: For sending request to server while something is not received or
>> >> time is expired.
>> >>
>> >> It is possible to use javaScript or beanShell for this needs.
>> >> But it is not clear for me to read and work with this plan...
>>
>> s> See above.
>>
>> >> If community wants I can send you patches to commit.
>>
>> s> Please don't e-mail patches - they should be provided via Bugzilla.
>>
>> >> But I think Function.java interface involves code duplication in several
>> >> places, such as the following example for Varialble.java:
>> >>
>> >> public synchronized void setParameters(Collection parameters) throws 
>> >> InvalidVariableException {
>> >>    values = parameters.toArray();
>> >>    if ((values.length < MIN_PARAMETER_COUNT) || (values.length > 
>> >> MAX_PARAMETER_COUNT)) {
>> >>        throw new InvalidVariableException("Parameter Count not between " 
>> >> + MIN_PARAMETER_COUNT + " & "
>> >>            + MAX_PARAMETER_COUNT);
>> >>    }
>> >> }
>> >>
>> >> I think it will be better to have:
>> >> protected int getMinParameterCount()
>> >> protected int getMaxParameterCount()
>> >>
>> >> and use them to verify parameters diapason and set it to values list for
>> >> all functions.
>> >> Also the following code construction is used 46 times for function
>> >> implementations:
>> >>
>> >> ((CompoundVariable) values[index]).execute()
>> >>
>> >> I think to extract this method to some utils
>> >> class in this package or to the AbstractFunction class, for example:
>> >>
>> >> protected (static?) String getParameter(Object obj)
>> >>
>> >> and so on...
>> >>
>> >> I understand that a lot of developers have own function implementation
>> >> based on Function API and it is not good to change this API but it is
>> >> possible to change AbstractFunction or add new super class extended from
>> >> AbstractFunction and use it for predefined functions.
>>
>> s> Quite possibly...
What way do you prefer?
I suggest to change AbstractFunction at the beginning.

>>
>> >> Just let me know if you want this refactoring too and I can do it. I
>>
>> s> If you are keen to do it, I suggest you provide a patch for just one
>> s> of the functions so it can be reviewed before further work is done.
>>
>> ok.
>>
>> >> need to know your opinion for changing only my stuff or to refactor
>> >> all other functions too.
Thank you.

--
Best regards,
Dmitry Kudrenko
ARDAS group (http://www.ardas.dp.ua)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to