How to pass null into Java keyword in remote library

135 views
Skip to first unread message

Thomas Maier

unread,
May 27, 2014, 7:36:06 AM5/27/14
to robotframework-users
Hi all,

We're using here javaremoteagent. For example my scenario looks like that:

Java remote test
Java Keyword val=X

I would like the X to be passed as null into Java code. I've tried
var=${None}, var=${NULL}, but
without any success. It's always passed as empty string.
Any ideas (is it possible at all)?

Thanks ahead.
Thomas

Kevin O.

unread,
May 27, 2014, 1:37:25 PM5/27/14
to robotframe...@googlegroups.com
The remote library API is based on the XML-RPC standard and is fully compliant (no vendor extensions). The standard provides no way of passing null values unfortunately. The Remote client and the Java server both automatically convert null/None values to empty strings (see the User Guide).

With the current behavior, you would have to work around the issue by something like converting an empty string into null inside the Java keyword. You could also declare the argument type as Object, and pass in ${0} to be a representation of null. In this case your keyword would receive the int or Integer 0 when the incoming type would otherwise be a String.

here's what using the magical number 0 might look like...
public void javaKeyword(Object val) {
    String newVal = null;
    if (val instanceof String) {
        newVal = (String) val;
    } else if (!Integer(0).equals(val)) {
        raise new IllegalArgumentException("val must be a string or 0")
    }
...

Thomas Maier

unread,
May 28, 2014, 4:59:07 AM5/28/14
to ombre42 ., robotframework-users
Hi Kevin,

Thanks for the prompt response. Converting string into null in the
keyword is indeed very simple solution.

Thomas
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at http://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages