Forum Discussion

kdbond's avatar
kdbond
New Contributor
17 years ago

Starting Mock Service Runner from within JUnit were test uses Axis2 client

I am having a problem with running a mock server from within my JUnit tests.  If I use the Maven plugin and just run the mock goal everything starts up and runs as expected.  However, when I run from JUnit all the log output looks correct and the port is opened and listening, but when I request the WSDL I just get a blank result.  I can't find any error messages anywhere so I am not sure where to look for the problem.  I suspect a jar version conflict, but I have tried soap UI 2.5.1 and 3.0-beta-2 and they both have the same result, and the 3.0-beta-2 have the smaller set of jar conflicts.

Baring getting this to run, I was trying to run the mock goal from Maven in the background of the test phase, but this does not work because if I run noBlock false the server starts and immediately exits and obviously if I block I will have to terminate the server before the tests run anyway.

Any idea how to get this working?

3 Replies

  • kdbond's avatar
    kdbond
    New Contributor
    To answer my own question...

    Axis2 depends on servlet-api-2.3, so I have to exclude that dependency from Maven in order for the jetty servlet-api jar to be seen.
  • Hi!

    easiest in your scenario might be to manually start the mockservice in your setup method(s) and stop it in the tearDown? ie in setup

    WsdlProject project = new WsdlProject( "pathtoprojectfile")
    WsdlMockService mockService = project.getMockServiceByName( ... )
    mockRunner = mockService.start()

    and then in tearDown

    mockRunner.stop()

    Is that an option?

    regards!

    /Ole
    eviware.com
  • kdbond's avatar
    kdbond
    New Contributor
    This is basically what I am doing, but I was having the conflict between Axis2 dependencies and soapui.  I have now resolved that issue by excluding servlet-api from the axis2 dependency tree.