Forum Discussion

nkpalli's avatar
nkpalli
Contributor
6 years ago

No such property: ProjectFactoryRegistry for class: Script1

Hello team,

 

while trying to execute groovy scripts embedded in a test suite via Launch test runner i am getting this below error : 

I am able to execute groovy script in standalone mode with no issues . Any pointers why is failing with this error ? or provide solution if you had encountered similar issue 

 

Here below is ReadyAPI Testrunner log generated 

 

10:17:08,991 ERROR [errorlog] groovy.lang.MissingPropertyException: No such property: ProjectFactoryRegistry for class: Script1
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)
10:17:08,997 ERROR [SoapUIProTestCaseRunner] Validate distinct Units in API response match DB failed, exporting to [C:\Program Files\SmartBear\ReadyAPI-2.3.0\bin\APITestSuite-APAPITests-Validate_distinct_Units_in_API_response_match_DB-0-FAIL.txt]

 

Here below is sample groovy script:

 

/*
NOTES: Run this groovy test script  
*/
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;integratedSecurity=true")

//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("NPAPI")
if(!prj.open && workspace!=null) workspace.openProject(testProject)
tCase = prj.testSuites['NPAPI-TestSuite'].testCases['NPAPI']
tStep = tCase.getTestStepByName("Validate NPAPI")
def runner = tStep.run(testRunner, context)
log.info ("runner status ....... : " + runner.hasResponse())

 

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

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

 


//Get PD date API returned
log.info(" Print PDate APAPI returned data for " + PDate)
def count = sortedJSON.size()
log.info('API count of Unit : ' + count)

 

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

 

//Compare API reponse string to DB string value

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