Previous Topic: Request Data EditorNext Topic: Match Script Editor Toolbar


Match Script Editor

To insert a sample match script for your information, right-click the Match Script panel. You can also switch the match script on or off by selecting or clearing the Do Not Use the Script check box.

To designate the scripting language, use the language drop-down on the lower right of the pane.

Language

Designates the scripting language to use.

Values:

Default: Beanshell

To hide or display line numbers, the editor toolbar, and the editor status bar, right-click on the left side of the Match Script panel, then select the appropriate options from the short-cut menu. The following graphic shows all options that are displayed.

Match Script Editor Stateless

A match script defines how VSE decides whether a specific transaction matches the incoming one. To receive a match that is based on the specific condition, write BeanShell scripts performing appropriate actions.

For example:

/* always match name=joe */ 
ParameterList args = incomingRequest.getArguments();
if ("joe".equals(args.get("name"))) return true else return 
defaultMatcher.matches(); 

You do not need to specify a match tolerance level or match operator for the match script to work. The match is found based on the condition in the match script.

By default (with no match script) an inbound request is matched against a service image request by comparing operations, arguments, or both to come to a true/false "Do they match?" answer. A match script simply replaces this logic with whatever logic makes sense and must still come to the true/false "Do they match?" answer.

The script can use the default matching logic. Inside the script, use the expression, "defaultMatcher.matches()". This expression returns a true or false using the VSE default matching logic.

The match script is similar to a scripted assertion. Basically, it is a regular BeanShell script but with the following additional variables preloaded for you (and the usual properties and testExec variable):

Return a Boolean value from the script; true means a match was found.

If there is an error evaluating the script, VSE deliberately ignores the error and defaults to the regular matching logic. If you do not think your script is being run, review the VSE log file.

A good way to add logging and tracing into your match scripts is to embed calls to the VSE matching logger. The VSE matching logger produces the messages in the vse_xxx.log file, where xxx is the service image name. For example:

import com.itko.lisa.VSE;
VSE.info(testExec, "short msg", "a longer message");
VSE.debug(testExec, "", "I got here\!\!");
VSE.error(testExec, "Error\!", "Some unexpected condition"); 
return defaultMatcher.matches(); 

If you log messages at INFO, later when the production settings are applied to the logging.properties file, the log level is WARN and your messages appear as a DevTest test event (a "Log Message" event).

Tips from logging.properties: