Forum Discussion

Brian_Mowbray's avatar
Brian_Mowbray
Contributor
15 years ago

Issue with context.findProperty using load test running

I have a test case in which I load up some settings into the project context during the project "Load Script" like:

log.info("start load script");
project.setPropertyValue("mykey", "myvalue");
log.info("value=" + project.getPropertyValue("mykey"));
log.info("end load script");


During the test case itself, I have a groovy script in which I access these value:

log.info("begin loading properties during test case");
def value = context.findProperty("myKey");
log.info("value=" + value);
log.info("done loading properties during test case");


This works fine from within the soapui GUI, but does not work from when launched via the load test runner (I use the following command to reproduce):

"C:\Program Files (x86)\eviware\soapUI-Pro-3.0.1\bin\loadtestrunner.bat" C:\\SampleReadContext-soapui-project.xml

The error that I get during the command line run is:

2010-04-07 16:36:53,971 ERROR [errorlog] groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext.findProperty() is applicable for argument types: (java.lang.String) values: [myKey]
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext.findProperty() is applicable for argument types: (java.lang.String) values: [myKey]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at Script1.run(Script1.groovy:2)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:59)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:50)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runTestStep(WsdlTestCaseRunner.java:197)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:128)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:39)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:137)
at com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTestRunner$InternalTestCaseRunner.run(WsdlLoadTestRunner.java:516)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)


Is there anything different about the context object used during the .bat vs gui?  (BTW: this is on soapui 3.0.1)
  • Hi Brian,

    hmm.. where did you find information about a findProperty method? I can't recall it ever being in the API !?

    try using

    def value = context.getProperty( "myKey" ).value

    instead.. does that work any better?

    regards!

    /Ole
    eviware.com
  • hmmm, very odd since it works from within the gui.  But I will give this a try.
  • nevermind, I found it.  Turns out that one of the other projects that I am loading had this in the startup sequence:

    com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext.metaClass.findProperty = { propertyName ->
        return delegate.getProperty(propertyName) ?:
                    delegate.testCase.getPropertyValue(propertyName) ?:
                    delegate.testCase.testSuite.getPropertyValue(propertyName) ?:
                    delegate.testCase.testSuite.project.getPropertyValue(propertyName)
    }

    This allowed it to work while the other project was loaded, but not when run in isolation
  • A second thought: would this functionality be something possible to roll into soapui by adding the method to the context class?
  • Hi Brian

    there is a getProperty( ".." ) method that does this, or you can use map-style indexing;

    def prop = testRunner.testCase.properties.nameofproperty

    or

    def prop = testRunner.testCase.getProperty( "nameofproperty" )

    does that help?

    regards!

    /Ole
    eviware.com
  • If I understand, the method you propose would find the property if you know where it is (i.e. it is in the scope of the test case) where this method traverses several locations (context.getProperty, then testCase.getPropertyValue, then test suite, then project).  Unless I am mistaken, there is not an existing soapui method that does this, right?

    delegate.getProperty(propertyName) ?:
                    delegate.testCase.getPropertyValue(propertyName) ?:
                    delegate.testCase.testSuite.getPropertyValue(propertyName) ?:
                    delegate.testCase.testSuite.project.getPropertyValue(propertyName)


    (the other thing that I didn't mention on this post is that this was a simplified version of the true use of it - there really is a desire to find properties at various levels to allow for optional override of values)