Forum Discussion

Lens's avatar
Lens
Occasional Contributor
16 years ago

NullPointerException when use runTestStepByName() for DataSink

Hi,

I was trying to run my teststep "DataSink" automatic by the groovy-script:

testRunner.runTestStepByName("DataSink")

But it creates an the following error:

Mon Jan 26 14:33:06 CET 2009:ERROR:java.lang.NullPointerException
  java.lang.NullPointerException
  at com.eviware.soapui.support.xml.XmlUtils.getValueForMatch(XmlUtils.java:1090)
  at com.eviware.soapui.model.propertyexpansion.resolvers.ResolverUtils.extractXPathPropertyValue(ResolverUtils.java:92)
  at com.eviware.soapui.model.propertyexpansion.resolvers.ModelItemPropertyResolver.resolveProperty(ModelItemPropertyResolver.java:81)
  at com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.expandProperties(PropertyExpansionUtils.java:143)
  at com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.expandProperties(PropertyExpansionUtils.java:98)
  at com.eviware.soapui.model.support.AbstractSubmitContext.expand(AbstractSubmitContext.java:245)
  at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
  at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
  at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:766)
  at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:754)
  at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
  at Script6.run(Script6.groovy:15)
  at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:59)
  at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:52)
  at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
  at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction.actionPerformed(GroovyScriptStepDesktopPanel.java:235)
  at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
  at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
  at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
  at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
  at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
  at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
  at java.awt.Component.processMouseEvent(Unknown Source)
  at javax.swing.JComponent.processMouseEvent(Unknown Source)
  at java.awt.Component.processEvent(Unknown Source)
  at java.awt.Container.processEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Window.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)

The fact is the values of the property list (of DataSink) are well filled in and when I will run it afterwards manual, it is no problem.

Is this the right way to do this in Groovy? Or are there other solutions for this?

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    this should be ok.. the error seems to be related to something else.. can you show the entire script?

    regards!

    /Ole
    eviware.com
  • Lens's avatar
    Lens
    Occasional Contributor
    Hi,

    The purpose of the script is the following.
    It's read the response, and catch al the data and write it to a Properties-step. Than I run the Property Transfer and the DataSink, so that the data will write out in a Excel-file.
    The response has a few standard topics, who will return several times. But I don't know how many times. That's why I use the while-loop.

    So here is the entire script.


    def a="true"
    def teller=0
    def teststep=""

    def inputFcli=""
    def inputFileDate=""
    def inputCreateDate=""
    def inputLoadDate=""
    def inputStatus=""
    def inputBillcycleStartDate=""
    def inputBillcycleEndDate=""
    def inputPrice=""
    def inputConso=""
    def inputIncludedVolume=""
    def inputUsedVolume=""

    //aanmaken teststep properties
    testRunner.testCase.addTestStep("properties","Objects")
    teststep=testRunner.testCase.getTestStepByName("Objects")
    teststep.addProperty('Fcli')
    teststep.addProperty('FileDate')
    teststep.addProperty('CreateDate')
    teststep.addProperty('LoadDate')
    teststep.addProperty('Status')
    teststep.addProperty('BillcycleStartDate')
    teststep.addProperty('BillcycleEndDate')
    teststep.addProperty('Price')
    teststep.addProperty('Conso')
    teststep.addProperty('IncludedVolume')
    teststep.addProperty('UsedVolume')


    while (a=="true"){
    teller++

    inputFcli=context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/fcli[1]}' )

    if (inputFcli!=""){
    //inlezen van response
    inputFileDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/filedate[1]}' )
    inputCreateDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/createdate[1]}' )
    inputLoadDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/loaddate[1]}' )
    inputStatus = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/status[1]}' )
    inputBillcycleStartDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcyclestartdate[1]}' )
    inputBillcycleEndDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcycleenddate[1]}' )
    inputPrice = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/price[1]}' )
    inputConso = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/conso[1]}' )
    inputIncludedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/includedvolume[1]}' )
    inputUsedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/usedvolume[1]}' )

    //response wegschrijven naar properties file
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Fcli', inputFcli)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('FileDate', inputFileDate)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('CreateDate', inputCreateDate)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('LoadDate', inputLoadDate)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Status', inputStatus)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleStartDate', inputBillcycleStartDate)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleEndDate', inputBillcycleEndDate)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Price', inputPrice)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Conso', inputConso)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('IncludedVolume', inputIncludedVolume)
    testRunner.testCase.getTestStepByName("Objects").setPropertyValue('UsedVolume', inputUsedVolume)

    //automatisch uitvoeren van teststeps
    testRunner.runTestStepByName("Property Transfer")
    testRunner.runTestStepByName("DataSink")

    }
    else {
    a="false"
    }
    }

    Regards,
    Benny
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Benny,

    Thanks! If I understand your initial post correctly, the script actually seems to be working ok ("the values of the property list (of DataSink) are well filled in"), just that you get this error message as well?

    regards,

    /Ole
    eviware.com
  • Lens's avatar
    Lens
    Occasional Contributor
    Hi Ole,

    Yes, that is correct.
    I have make yesterday some tests, and I have discovered that the error is thrown at the end of the script. But I don't know the reason.
    But the runTestStepByName() for the DataSink seems not to be working.
    The icon (of DataSink in the Navigator-panel) colors red after the script has run. Than I can see that the (last) values are well filled in in the properties of the DataSink, but the synchronisation is not happened.
    So, the script runs not completely. 

    regards,
    Benny