What is the Match Script Tab in VSE?

Document ID : KB000048402
Last Modified Date : 14/02/2018
Show Technical Document Details

There is full parseInState() support for VSE responses that means BeanShell is supported. It's also supported on the request side for when you need to script whether a request in the service image matches the inbound one.

With regard to request matching scripts:

  • Does the script just need to end in a "return true" or "return false"? Yes

  • I assume this could also modify the incoming request? Theoretically, it could but that would be a bad idea.

  • When in the process does the match script run, after a specific is selected? If so, is there a place I can put a "common" match script for an operation? It is executed any time the inbound request is matched against the containing transaction. So you could have a match script at either (or both) the meta and specific levels.

  • What happens if the match script rejects the match? The same thing that happens if the inbound request operation and/or arguments don't match the service image request.

By default (that is, no match script) an inbound request is matched against a service image request by comparing operations and/or arguments to come to a true/false "do they match?" answer. A match script simply replaces this with whatever logic makes sense and must still come to the true/false "do they match?" answer. The script does have the ability to make use of the default matching logic if it needs to.

  • How would one do that? Inside the script, use the expression, "defaultMatcher.matches()". This will return a true or false using VSE's default matching logic.

It's a lot like a scripted assertion, basically a regular BeanShell script but with three additional variables preloaded for you (as well as the usual properties and 'testExec' variable):

 com.itko.lisa.vse.stateful.model.Request sourceRequest //(the recorded request)       
 com.itko.lisa.vse.stateful.model.Request incomingRequest //(the live request coming in) 
 com.itko.lisa.VSE.RequestMatcher defaultMatcher //(you can default to this guy if you want)
 You need to return a Boolean value from the script; true means a match was found.

Here is an example:

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