Forum Discussion

NMeyer's avatar
NMeyer
Occasional Contributor
13 years ago

[Resolv.]Data-driven test with multiple logins exception ..

I have a data-driven test case that is attempting to login, test api a, test api b, logout, and then datasource loop back to login. The username and password for each login are coming from excel along with the api verification items for the api tests. The first time though the test case everything works fine, but after the datasource loop, every subsequent login fails with the following exception:

Fri Oct 11 09:08:12 EDT 2013:ERROR:java.io.IOException: Attempted read from closed stream.
java.io.IOException: Attempted read from closed stream.

I'm assuming this is due to the fact, that in order to get the test case to be successful, I had to enable the Maintain Http Session option, so all of the subsequent logins are attempting to login to a session that has already been logged off. Is there another setting that would enable me to maintain a unique session for each run through the datasource?

I attempted to modularize the test case by splitting our the login steps to their own test case and then call that from the main api test case (not 100% sure that would even fix my issue). In the event that this would fix my issue, I'd need to keep the datasource in the main api test case and then reference from the login test case using a groovy test script. I'm guessing I'd need to use context.expand to reference the datasource test step, but I'm not sure of the syntax for that.

Any help here would be much appreciated.

Thanks!

22 Replies

  • Hmmm ... Maybe this will work:

    import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport
    import com.eviware.soapui.model.iface.SubmitContext

    def httpContext = HttpClientSupport.createEmptyContext()
    // add things to the BasicHttpContext object, if necessary
    context.setProperty( SubmitContext.HTTP_STATE_PROPERTY, httpSupport)

    Best regards,
    Manne
  • NMeyer's avatar
    NMeyer
    Occasional Contributor
    HEY NOW!!! Adding that right after terminating the existing session makes my test case work! Thank you so much for the help. Is there anyway to test/confirm what Michael suspected, that there may be a bug in the way cookies are being stored for REST services? I would consider my issue resolved, just not sure if there is any further investigating that needs done on that front. Thank you so much for the help!