cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
170
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 23-11-2006 04:18:14 PM
Hi,

We have a growing collection of Action (and Voice) elements and I wanted to write some JUnit tests for validation during development.

This is OK for the standard getElementName() and getSettings() methods but I have run into problems with doAction (and addXmlBody) because I haven't been able to create instances of Audium's ActionElementData object etc.

I've tried various work arounds, such as separating functionality into methods that don't require ActionElementData but ultimately the test is only any good if it calls the doAction method, as CallServices will.

Any advice on how to create these objects.

Thanks

Marc

Subject: RE: Creating ActionElementData objects
Replied by: null on 28-11-2006 07:55:40 PM
Good post.

I have also tried a similar strategy recently, and found, as you did, that instantiating one of these classes allowed me to call getElementName(), getDescription() etc and walk the Settings[] array. All pretty useless.

I have written some pretty complex Action Elements (like sending XML over HTTP and over sockets) and this has been my strategy. In the doAction() method I call another method that does the heavy lifting.

In order to pass data back to the doAction() element and obey the Audium constraints, I declare an inner class and my new method returns an object of that class, with a whole bunch of things filled in. This method has local tracing to a file.

Back in the doAction() I pull off the items I need and add them as session variables or write into the Audium log. The usual stuff.

Then I write a parallel test class that calls the same heavy lifting method (actually I create this class first).

The method is EXACTLY the same, and once I get the test class working I copy the method unchanged into the action element. If I detect a problem, I change the code in the test class and again, copy the method in to the action element Java file - and store both files in ClearCase or CVS. Then I have a .BAT file to call the test class, passing in whatever test parameters I need.

Because this method writes trace information in a local file, I can verify that the method is working correctly before I sign it up to Audium. You could use System.out too if you liked, but I create files using the timestamp in the file name to separate them.

I have a setting that turns off the tracing at the Audium application level once all is well.

This method has worked well for me - I'd be interested in your take on this.

Regards,
Geoff

Subject: RE: Creating ActionElementData objects
Replied by: Michael Bochynski on 07-12-2006 01:42:56 PM
Hi Geoff,

I like your approach. As a developer, I always test each entity, either class or method, separately and as much independently as possible, before putting things together. Once every component works as expected, I combine all the elements together making sure that the interaction between them works fine and try to make as few changes as possible to each entity.

This approach works very well especially in web development, when working with web services.

Regards,
Michael

Subject: RE: Creating ActionElementData objects
Replied by: null on 19-12-2006 11:25:41 AM
Hi Geoff/Michael,

Appologies for the delay in replying and thanks for the responses.

It looks like I've implemented something similar, by decompsing activities into testable methods which are recombined (finally) in the addXML or doAction method(s).

I guess the weak point remains the doAction method though, since some processing must be carried out here to extract Setting or variable values from the Audium runtime.

In an ideal world, you might want to test a live situation and this would most effectively be simulated by creating Audium runtime components. The current solution requires interpretation of the runtime in order to call the worker methods, which may well invalidate the test. Some simple examples might be Audium's substitution of empty strings for missing variables or null for empty element properties?

Thanks again

Marc

Subject: RE: Creating ActionElementData objects
Replied by: null on 20-12-2006 03:12:49 AM
[quote:3fe987c93b]I guess the weak point remains the doAction method though, since some processing must be carried out here to extract Setting or variable values from the Audium runtime.[/quote:3fe987c93b]

I'd agree with that Marc. It's obviously hard to do because it's all wrapped up in the runtime.

I think you've done all you can do. Here's a question though - when passing back multiple data elements from a function called by doAction(), did you create an inner class? I know that method works, but I wondered if there was another approach.

Regards,
Geoff
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links