Forum Discussion

RJanecek's avatar
RJanecek
Regular Contributor
13 years ago

NPE in groovy test step

Hi I have some test step. And when soapui run groovy script there is NPE but I dont know why:

08:14:15,600 ERROR [SoapUI] An error occured [java.lang.NullPointerException], see error log for details
08:14:15,601 ERROR [AbstractTestRunner] Exception during Test Execution
java.lang.NullPointerException
at com.eviware.soapui.report.JUnitReportCollector.afterStep(JUnitReportCollector.java:168)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:244)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:141)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:42)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
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$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


this is all I have

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    hmm... can you show the contents of the groovy script?

    regards!

    /Ole
    SmartBear Software
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

    def response = context.expand( '${Request#Response}' )
    def holderResponse = groovyUtils.getXmlHolder( response )


    def listElement = []
    int countElement1 = Integer.parseInt (holderResponse.getNodeValue( "count(//*[local-name()='element1' and namespace-uri()='cz:v1'])") )
    for(int i = 1; i <= countElement1; i++){
    listElement.add( holderResponse.getNodeValue( "//*[local-name()='element1' and namespace-uri()='cz:v1'][" + i + "]" ) )
    listElement.add( holderResponse.getNodeValue( "//*[local-name()='element1' and namespace-uri()='cz:v1'][" + i + "]/@atribut" )
    }
    Collections.sort(listElement)
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    hm maybe I found where is the mistake. Sometimes in this list is null object and when I want to sort it there is NPE but I dont know why it print this exception and groovy didnt tell me row where is mistake
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    yes, that makes sense - maybe you can avoid adding null items to the collection somehow?

    regards!

    /Ole
    SmartBear Software
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    yea there is null but why it show this exception so I cannot see my fault immediately ?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    you are of course right - it is a bug in soapUI to not handle this correctly - I've added it to the backlog for fixing.

    regards!

    /Ole
    SmartBear Software