Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Custom Jython Responder Correlation

Options
jdubreuil
jdubreuil Posts: 1

In V9.1x, has anyone been able to get a custom correlation to work that uses regex? Example below

from java.util.regex import *
from java.lang import * 
from com.parasoft.api import *

def correlateOperation(context):
    requestHeadersStr = context.get(CorrelationScriptingHookConstants.HEADERS)      # Map<String, String>
    requestBodyBytes = context.get(CorrelationScriptingHookConstants.MESSAGE_BIN)   # byte[]
    requestBodyDoc = context.get(CorrelationScriptingHookConstants.MESSAGE_DOM)     # Document
    requestBodyStr = context.get(CorrelationScriptingHookConstants.MESSAGE_STR)     # String
    requestMethod = context.get(CorrelationScriptingHookConstants.REQUEST_METHOD)   # String
    requestUrl = context.get(CorrelationScriptingHookConstants.REQUEST_URI)         # String
    requestUrlParamsMap = context.get(CorrelationScriptingHookConstants.URL_PARAMS) # Map<String, String[]>
    attachments = context.get(CorrelationScriptingHookConstants.ATTACHMENTS)        # List<com.parasoft.api.ICorrelationAttachment>


    p = Pattern.compile("a*b");
    m = p.matcher(String("aaaab"));  
    return m.find()