How to call Java code from soapUI?
Hi - this may be a Groovy question rather than a real soapUI question, but soapUI is the reason I am now digging into Groovy, so please bear with me:
I am trying to get a bit more information why one of my regular expressions doesn't match. Unfortunately, a statement like "assert response =~ pattern" returns essentially just yields a thumbs up/down result without any indication whatsoever why something didn't match.
I was thus trying to use some good, ol' Java code to get a bit more feedback. The PatternSyntaxException that Pattern throws if a match fails would allow to get a bit more details (error index, etc.). So I was trying a code snippet like the below:
def matches = false try { log.info('1') matches = java.util.regex.Pattern.matches(pattern, response) log.info('2: ' + matches) } catch (java.util.regex.PatternSyntaxException psx) { log.info(psx.getMessage()) } catch (Exception ex) { log.info(ex) } assert matches
Why does this always only reach the "log.info('1')" statement and then ends in an "Error: null" popup?
I though, one of the big advantages of Groovy is that I can use plain Java code whenever I want or need to. Why does this not work here? What am I missing?
Hi,
No problem, happy if I can help, but it sounds like there may be a deeper problem as you are pointing out...
What you are saying does sound reasonable in that possibly the SoapUI Java memory usage is an area that may be affecting the ability to run your regex... don't expect the response is the problem...
As you may be aware to change the Java options for SoapUI you can alter the soapui.sh (or .bat) script - refer to http://www.soapui.org/working-with-soapui/improving-memory-usage.html for more details.
Guess you may try increasing the -Xss stack space parameter as you said...
Let us know how you get on please, possibly it would be good to share your regex if you're happy too, just incase that helps or attracts other useful advice...
Cheers,
Rupert