On 26/11/2007, Dmitry Kudrenko <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I need to implement the following functions for my testplan:
> 1. long __timestamp()
>   returns new Date().getTime()

${__time()}

> 2. long __timeDuration(String variableName)
>   returns new Date().getTime() - variables.get(variableName)

${__intSum(${__time()},-${variableName})}

> 3. boolean __isTimeoutExpaired(String variableName, long timeout)
>   returns true if __timeduration for variableName more than specified
>   timeout.

${__javaScript(${variableName} > timeout)}

>

> 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...

See above.

> If community wants I can send you patches to commit.

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.

Quite possibly...

> Just let me know if you want this refactoring too and I can do it. I

If you are keen to do it, I suggest you provide a patch for just one
of the functions so it can be reviewed before further work is done.

> need to know your opinion for changing only my stuff or to refactor
> all other functions too.
>
>
> --
> Best regards,
> Dmitry Kudrenko
> ARDAS group (http://www.ardas.dp.ua)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to