Forum Discussion
HP-Plano-TX-Soa
13 years agoOccasional Contributor
Hi Rao,
I get no errors in the compilation of the groovy scripts nor in the creation of the JAR file. I do place the JAR file in the ....\bin\ext\ dir and restart SoapUI Free - but the same error occurs. Here is the source code so you can see what I am doing:
Here is a call I make to my custom Teardown() method, from inside the soapUI TestCase Teardown Script:
Here is the groovy script itself:
Here is the error I get when trying to run the TestCase in soapUI Free after compiling, building the JAR, placing it in ...\bin\ext\ and restarting soapUI Free:
groovy.lang.MissingPropertyException: No such property: com for class: customScripts.teardownScripts
Possible solutions: log
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at customScripts.teardownScripts.Teardown(teardownScripts.groovy:86)
at customScripts.teardownScripts$Teardown.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at Script1.run(Script1.groovy:2)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.runTearDownScript(WsdlTestCase.java:953)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTearDownScripts(AbstractTestCaseRunner.java:203)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:184)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:43)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:163)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Line 86 in my groovy script is exactly the line where I reference the com.eviware.soapui.SoapUI.logMonitor object.
What am I doing wrong? This all works perfectly in soapUI Pro with the groovy source code package folder (customScripts) placed in the ....\bin\scripts\ dir. But in the Free version it can't seem to find the "com" property.
I get no errors in the compilation of the groovy scripts nor in the creation of the JAR file. I do place the JAR file in the ....\bin\ext\ dir and restart SoapUI Free - but the same error occurs. Here is the source code so you can see what I am doing:
Here is a call I make to my custom Teardown() method, from inside the soapUI TestCase Teardown Script:
def tdscript = new customScripts.teardownScripts(log, context, testRunner, testCase)
tdscript.Teardown()
Here is the groovy script itself:
package customScripts;
import com.eviware.soapui.SoapUI.logMonitor.*;
class teardownScripts
{
def log
def context
def testRunner
def testCase
teardownScripts(log, context, testRunner, testCase)
{
this.log = log
this.context = context
this.testRunner = testRunner
this.testCase = testCase
}
def Teardown()
{
def testStep;
def tstype;
def tsname;
def myRequestStep;
def request;
def response;
def sts;
context.fileReader.close()
if (context.expand('${#TestCase#ScriptLogVerbose}') != "YES")
{
return
}
// Log the testCase name, status and all the testStep messages
//
def testCaseName = testRunner.testCase.name
log.info testCaseName
if ( testRunner.getStatus().toString() == 'FAILED' )
{
log.info ("$testCaseName has failed")
}
else
{
log.info ("$testCaseName has Passed")
}
for ( testStepResult in testRunner.getResults() )
{
testStep = testStepResult.getTestStep()
tstype = testStep.config.type
// log.info tstype
tsname = testStepResult.testStep.name
myRequestStep = testRunner.testCase.getTestStepByName("$tsname")
if ( tstype == "request" && myRequestStep.testRequest.messageExchange != null)
{
request = new String(myRequestStep.testRequest.messageExchange.rawRequestData)
response = new String(myRequestStep.testRequest.messageExchange.rawResponseData)
log.info ("\r\n\r\n" + "**** " + "$tsname: RAW REQUEST: " + request + "\r\n\r\n")
log.info ("\r\n\r\n" + "**** " + "$tsname: RAW RESPONSE: " + response + "\r\n\r\n")
}
sts = testStepResult.getStatus().toString()
log.info ("$tsname has status of: " + "$sts")
testStepResult.messages.each() { msg -> log.info (tsname + ": " + msg) }
}
if (context.expand('${#TestCase#SaveLogFiles}') != "YES")
{
return
}
// Give SoapUI script logging a chance to catch up before attempting to capture the script log to a file
sleep (5000)
// Save the TestCase Log, error log and script log to a combined log file
//
// "soapUI log" can be replaced with http log, jetty log, script log, error log etc based on the need.
def logArea = null
def logMon = [b]com[/b].eviware.soapui.SoapUI.logMonitor
if ( logMon != null ) {
logArea = [b]com[/b].eviware.soapui.SoapUI.logMonitor.getLogArea( "script log" )
}
def path = context.expand('${#Project#Log_files_loc}')
def date = new Date()
def datefmt = new java.text.SimpleDateFormat('yyyy_MM_dd_kkmmss')
def timestamp = datefmt.format(date)
log.info timestamp
def logFile = new File(path + testCaseName + "_" + timestamp + ".txt")
log.info (path + testCaseName + "_" + timestamp + ".txt")
logFile.write("============================= SCRIPT LOGS: ===============================\r\n\r\n")
if( logArea != null )
{
def model = logArea.model
if( model.size > 0 ) {
for( c in 0..(model.size-1) ) {
logFile.append(model.getElementAt( c ).toString() + "\r\n")
}
}
}
}
}
Here is the error I get when trying to run the TestCase in soapUI Free after compiling, building the JAR, placing it in ...\bin\ext\ and restarting soapUI Free:
groovy.lang.MissingPropertyException: No such property: com for class: customScripts.teardownScripts
Possible solutions: log
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at customScripts.teardownScripts.Teardown(teardownScripts.groovy:86)
at customScripts.teardownScripts$Teardown.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at Script1.run(Script1.groovy:2)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.runTearDownScript(WsdlTestCase.java:953)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTearDownScripts(AbstractTestCaseRunner.java:203)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:184)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:43)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:163)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Line 86 in my groovy script is exactly the line where I reference the com.eviware.soapui.SoapUI.logMonitor object.
What am I doing wrong? This all works perfectly in soapUI Pro with the groovy source code package folder (customScripts) placed in the ....\bin\scripts\ dir. But in the Free version it can't seem to find the "com" property.