RCPTT running Java code from the script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



RCPTT running Java code from the script



I am looking for some way to run some Java code directly from the test script I am writing for our RCP application.



I need to set up a multi-cast socket in the test before clicking a particular button in the application. Something like this:


MulticastSocket socket = new MulticastSocket();
socket.setNetworkInterface(interfaceTarget);

InetAddress group = InetAddress.getByName("220.2.2.2");
socket.joinGroup(group);



I was unable to find any way to do this just wondering if this is possible?




1 Answer
1



You cannot execute arbitrary Java Code directly (i.e., by writing or referring to Java code in your script), because the AUT runs in a separate process and you only can communicate from the outside.



In other words, the script executes in your RCPTT IDE or test runner process. The actual application under test (AUT) just includes the RCPTT runtime which effectively opens a telnet socket by which it receives commands and sends results via a textual language. Therefore, everything must stick to that protocol and you cannot do anything not specified by the protocol out of the box.



That said, you can call existing Java classes and methods in your AUT via the invoke and invoke-static script commands.


invoke


invoke-static



Precondition for invoke is that you are able to retrieve an object reference via the scripting language.
E.g., you can use


invoke


<get-something-from-somewhere> | get-object | invoke methodName arg0 arg1 ...



Precondition to call a static method via invoke-static is that the method you want to call is accessible from within the AUT. To achieve this (and if your desired method is not part of the AUT already), you can add a test support bundle into your AUT which declares the static method. This way you could implement the code snippet given in your question.


invoke-static



Finally, as the third and most advanced option, you can add your own ECL commands. This is done by implementing an extension point defined by the AUT runtime and including the implementation as bundle in your AUT (similar to the invoke-static approach, but much more flexible, because you can build command chains.


invoke-static



For all three cases, this link serves as a starting point to executing any kind of custom code in the AUT...





In the end we did not go with RCPTT for our testing but this would have allowed the calling of java...would have preferred if it wasn't a bit of a chore to write the commands though...but thanks for the answer I will accept it for other peoples reference
– BrendanM
Mar 31 '17 at 16:17





@Stefan Winkler, the answer is not clear to me. Can you please give some more details or some more helpful link?
– noor
Jan 12 at 16:26





@BrendanM which tool you have implemented finally instead of rcptt?
– noor
Jan 12 at 16:27





@noor, I have enhanced by answer a bit. HTH...
– Stefan Winkler
Jan 13 at 18:02






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard