Handling Test Case Data in VoiceObjects 7.4
January 7th, 2009 by Andreas VolmerIn short, you need to handle sets of test data, each set representing a certain test case. Of course, there are several options to deal with this, but as of VoiceObjects 7.4, you now have a very elegant solution at our fingertips: The new expression function APPLYCONFIGURATION.
What does it do? Let’s have a look at the inline documentation in the Expression editor:
APPLYCONFIGURATION (configurationXML) – Applies the assignments defined in configurationXML. The XML format used is the same as for application defaults.
Application Defaults
Have you used the application defaults functionality before? If not – it’s simple: It’s about initializing selected variables, layers and collections on the service level. The Service object references an XML configuration file in the Configuration URL field. This configuration XML file will be loaded whenever the service is (re-)deployed. (For more information, check out the section on Application Defaults in the VoiceObjects Deployment Guide.)
The primary use case for Application Defaults is this: When working in multiple environments such as, say, a development, a test, and a production environment, each of those will require some unique configuration settings. For example, database names and credentials might differ, resource locator paths, and any other external settings. By “outsourcing” the initialization of the environment-dependent variables to the “application defaults” configuration XML document (which is bound to the service object, not to the project), the project definition itself becomes agnostic of the environment and can hence easily be taken from “dev” to “test”, and from “test” to “prod”, without applying any changes to the project.
For an example of a valid configuration XML file, scroll down to the bottom of this posting. In a nutshell, a configuration XML file references any number of variables, layers, and collections in a given project (by reference ID) and defines their initial values.
In-Session Configuration
Now, VoiceObjects 7.4 takes this concept one step further and makes the same mechanism available on a per-session basis: You can do bulk assignments of variables, layers and collections in a single step within your call flow definition, applying different sets of values for each and every call. Of course, this comes in very handy when you need to manage test case data.
Let’s have a look at our Prime Telecom demo application. It supports 3 different languages and 2 different customer types. For each of the resulting 3×2 = 6 combinations, we need at least one test case.
In the previous version of Prime Telecom, these test cases were handled in the traditional way: Within the Preprocessing sequence of the main Module Prime Telecom Portal, a Connector object invoked a JSP, providing the current language and the customer status as request parameters. As response parameters, the Connector’s parameter set contained each and every variable and collection that needed to be initialized – the customer’s postal address, email address, payment information, current tariff, subscribed tariff add-ons, available tariff add-ons etc. Quite a few parameters had to be maintained. And whenever a new parameter had to be added, it had to be added both in the JSP implementation and to the Connector object’s parameter set. Also, the maintenance of the test data in that JSP was cumbersome at best.
Not so any more.
The new implementation of test case data handling in Prime Telecom relies on test data being organized in configuration XML files, each file representing one test case. In Prime Telecom, these files are named configuration_de-DE_platinum.xml, configuration_de-DE_silver.xml, configuration_en-UK_platinum.xml etc.
In the Preprocessing sequence of the main Module Prime Telecom Portal,
- a Connector object reads the configuration XML file (via http get) for the current language and customer status and assigns its content to a variable;
- this variable is then used as the argument of an APPLYCONFIGURATION expression, setting all required variables and collections at once.
The beauty if this solution is that there is only one place to maintain the test data: In the configuration XML documents. When adding more parameters, only the XML documents need to be adapted; the Connector implementation (in our case, some Java code) and the Connector object’s parameter set remain unchanged. Also, the configuration XML documents are much easier to read and hence to maintain than the old JSP.
Of course, there are more use cases to APPLYCONFIGURATION than “just” handling test cases. For example, a hosted service provider could build application templates which become adapted to each customer’s requirements using this mechanism. Also note that, using VoiceObjects’ web service interface, much of the necessary handling could be automated, creating easy-to-use web front ends for end customers.
Example for a valid configuration XML document
This example shows how two objects are being initialized - the variable with the RefID CustomerBaseTariffName, and the collection with the RefID CustomerPaymentSettings. Note that the <type> nodes are optional; also note that collections need to be masked by <![CDATA[ ... ]]> sections.
<?xml version=”1.0″ encoding=”UTF-8″?>
<configurations>
<configuration>
<referenceID>CustomerBaseTariffName</referenceID>
<type>variable</type>
<value>Individual Plan</value>
</configuration>
<configuration>
<referenceID>CustomerPaymentSettings</referenceID>
<type>collection</type>
<value><![CDATA[
<root>
<row>
<col name="type">Visa</col>
<col name="number">4140040912440644</col>
<col name="expdate">0210</col>
</row>
</root>
]]></value>
</configuration>
</configurations>
Tags: Prime Telecom, VoiceObjects 7.4






January 7th, 2009 at 3:38 pm
Very interesting! One question, though: do you need to instrument your application to support those test cases (i.e. with code that must be removed when deploying the application in production)? Maybe I’m not familiar enough with VO….
January 8th, 2009 at 11:13 am
Yes, you’d instrument those test cases. I.e., you’d have both the “real” back-end connector objects and back-end “stubs” side by side. (In most cases you can even do without any “stubs”.)
You wouldn’t need to “remove” any code for production though, but rather (de-)activate those objects with a (boolean) flag that is used as precondition. This flag could be a variable that is set, e.g., in the “application defaults” configuration XML document. Hope this helps!