Forum Discussion

nkpalli's avatar
nkpalli
Contributor
6 years ago

project factory registry

 

Hello team,

 

I am getting this error while trying to execute groovy script via Launch Test Runner . when I try to run the groovy script in standalone mode i don't encounter this issue . can any one help me point out issue and provide any solution if you had encountered the same 

 

Here below is the ReadyAPI Test Runner log message:

 

10:17:09,010 INFO [SoapUIProTestCaseRunner] TestCase [APAPITests] finished with status [FAIL] in 1831ms
groovy.lang.MissingPropertyException: No such property: ProjectFactoryRegistry for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at Script1.run(Script1.groovy:29)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:98)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:82)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:156)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:260)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:50)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:170)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:1)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:72)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:685)
at com.eviware.soapui.impl.wsdl.WsdlTestCasePro.run(WsdlTestCasePro.java:104)
at com.eviware.soapui.impl.wsdl.WsdlTestCasePro.run(WsdlTestCasePro.java:93)
at com.smartbear.ready.cmd.runner.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:695)
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.runTestCase(SoapUIProTestCaseRunner.java:245)
at com.smartbear.ready.cmd.runner.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:419)
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.runRunner(SoapUIProTestCaseRunner.java:99)
at com.smartbear.ready.cmd.runner.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:276)
at com.smartbear.ready.cmd.runner.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:175)
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.init(SoapUIProTestCaseRunner.java:83)
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.main(SoapUIProTestCaseRunner.java:79)

 

 

 

Here below is sample groovy script 

 

/*
NOTES: Run this groovy test script to validate Clients match DB results
*/
import groovy.json.JsonSlurper
import groovy.xml.XmlUtil
import groovy.sql.Sql
import groovy.sql.GroovyRowResult

// Set Project level attributes
def dbServer = context.expand( '${#Project#DatabaseServer}' )
def dbport = context.expand( '${#Project#port}' )
def dbInstance = context.expand( '${#Project#DatabaseInstance}' )
def dbname = context.expand( '${#Project#DatabaseName}' )
def projectworkspace = context.expand( '${#Project#ProjectWorkspace}' )

//Connection setup to database Instance
//sql = Sql.newInstance("jdbc:sqlserver://$dbServer:$dbport;instanceName=$dbInstance;databaseName=$dbname;username=$dbusername;password=$dbpassword")

//Exesute NewPricingAPI call using testrunner variable

def workspace = testRunner.testCase.testSuite.project.workspace
def prj = (workspace==null) ?
ProjectFactoryRegistry.getProjectFactory(WsdlProjectFactory.WSDL_TYPE).createNew("$projectworkspace") :
workspace.getProjectByName("APAPI")
if(!prj.open && workspace!=null) workspace.openProject(testProject)
tCase = prj.testSuites['APAPI-TestSuite'].testCases['APAPITests']
tStep = tCase.getTestStepByName("Validate APAPI")
def runner = tStep.run(testRunner, context)
log.info ("runner status ....... : " + runner.hasResponse())

// Using Json Slurper class method to read APAPI response values

def Response = context.expand( '${Validate APAPI#Response}' )//creating instance of slurperclass
def slurperResponse = new JsonSlurper().parseText(Response)
def sortedJSON = slurperResponse.data.units.sort {it.unit_id}
log.info(sortedJSON)

//Get the count of Unit in API response to validate against db count

log.info(" Print APAPI returned data for " + PDate)
def count = sortedJSON.size()
log.info('API count of Unit_ID : ' + count)


// SQL Query to Pull Database values
def result = sql.firstRow("""
select * from AP
""")
dbproperty = result.toString()
log.info('Count of unitID in Database :' + dbproperty)

//Compare API reponse string to DB string value

if (count.toString() == dbproperty.toString())
log.info ("Count match DB")
else
log.info ("Count do not match DB")

1 Reply

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    Hi,

     

    Thank you for creating the case. Please try to import the following classes:

     

    import com.eviware.soapui.model.project.ProjectFactoryRegistry
    import com.eviware.soapui.impl.wsdl.WsdlProjectFactory