Forum Discussion

djangofan's avatar
djangofan
Contributor
12 years ago

Help me troubleshoot my simple mock service project?

I was wondering if anyone could help me troubleshoot a project that I have. I have kept it as simple as possible, being a SoapUI Mock service test with 2 assertions.

Here is my project:
https://github.com/djangofan/soapui-test

And here is the error it gives me when I run:
eviware:maven-soapui-plugin:mock eviware:maven-soapui-plugin:test


And here is the error I get when I execute that:

2013-06-26 17:06:29,342 WARN  [SoapUI] Missing folder [C:\Eclipse64\workspace\soapui-test\.\ext] for external libraries
2013-06-26 17:06:29,521 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\u0163410\soapui-settings.xml]
2013-06-26 17:06:30,100 INFO [SoapUI] File [C:\Eclipse64\workspace\soapui-test\src\test\resources\timeservice-soapui-project.xml] does not exist, trying URL instead
2013-06-26 17:06:30,100 ERROR [SoapUI] An error occured [unknown protocol: c], see error log for details
2013-06-26 17:06:30,101 ERROR [errorlog] java.net.MalformedURLException: unknown protocol: c
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(URL.java:592)
at java.net.URL.<init>(URL.java:482)
at java.net.URL.<init>(URL.java:431)
at com.eviware.soapui.impl.wsdl.WsdlProject.<init>(WsdlProject.java:261)
at com.eviware.soapui.impl.wsdl.WsdlProjectFactory.createNew(WsdlProjectFactory.java:41)
at com.eviware.soapui.impl.wsdl.WsdlProjectFactory.createNew(WsdlProjectFactory.java:24)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:337)
at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:158)
at com.eviware.soapui.maven2.TestMojo.execute(TestMojo.java:113)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Your project executed absolutely fine along with assertions for me in soapui. Please see the screen shot.
    Unfortunately, i do not have maven plugins and not comfortable with it. So, you experience the issue when it is executed with maven ? what is soapui version?
  • Your right, it looks like I need the following tag in my pom.xml configuration:

    <mockService>TimeServiceSOAP MockService</mockService>


    Sadly, the documentation doesn't even mention that tag:
    http://www.soapui.org/Test-Automation/maven-2x.html

    I'll give that a try. I was definitely already including both the mock and test goals when I was running it and so this hopefully turns out to be the solution.
  • Ok, I am much closer to getting it working (see GitHub link above). I am executing the "mock" step just before the "test" step, but strangely, the "mock" step blocks and says "Press any key to terminate..." and doesn't execute the "test" goal until you hit the key and it terminates. So, how do I get the "mock" service to keep running until the "test" goal finishes?

    09:56:47,356 INFO  [JettyMockEngine] Started mockService [MockService] on port [8088] at path [/mockTimeServiceSOAP]
    09:56:47,357 INFO [SoapUIMockServiceRunner] MockService started on port 8088 at path [/mockTimeServiceSOAP]
    09:56:47,358 INFO [SoapUIMockServiceRunner] Started 1 runner
    Press any key to terminate...

    09:57:10,358 INFO [JettyMockEngine] Stopped MockService [MockService] on port [8088]
    09:57:10,359 INFO [SoapUIMockServiceRunner] MockService stopped, handled 0 requests
    09:57:10,360 INFO [SoapUIMockServiceRunner] time taken: 23942ms
    [INFO]
    [INFO] --- maven-soapui-plugin:4.5.0:test (default-cli) @ soapui-test ---
    [DEBUG] Configuring mojo eviware:maven-soapui-plugin:4.5.0:test from plugin realm ClassRealm[plugin>eviware:maven-soapui-plugin:4.5.0, parent: sun.misc.Launcher$AppClassLoader@21353d27]
    [DEBUG] Configuring mojo 'eviware:maven-soapui-plugin:4.5.0:test' with basic configurator -->
    [DEBUG] (f) endpoint = http://127.0.0.1:8088/mockTimeServiceSOAP
    [DEBUG] (f) globalProperties = [gmessage=Hello Global!]
    [DEBUG] (f) host = http://127.0.0.1:8088
    [DEBUG] (f) junitReport = true
    [DEBUG] (f) outputFolder = C:\Eclipse64\workspace\soapui-test\target/soapui-reports
    [DEBUG] (f) printReport = true
    [DEBUG] (f) projectFile = C:\Eclipse64\workspace\soapui-test/src/test/resources/timeservice-soapui-project.xml
    [DEBUG] (f) projectProperties = [pmessage=Hello Project!]
    [DEBUG] (f) settingsFile = C:\Users\u0163410/soapui-settings.xml
    [DEBUG] (f) soapuiProperties = {soapui.scripting.library=src/test/resources, soapui.logroot=C:\Eclipse64\workspace\soapui-test\target/soapui-logs/}
    [DEBUG] (f) testCase = RequestTime TestCase
    [DEBUG] (f) testSuite = TimeServiceSuite
    [DEBUG] -- end configuration --
    soapUI 4.5.0 Maven2 TestCase Runner
    09:57:10,403 INFO [SoapUITestCaseRunner] Setting global property [gmessage] to [Hello Global!]
    Setting soapui.scripting.library value src/test/resources
    Setting soapui.logroot value C:\Eclipse64\workspace\soapui-test\target/soapui-logs/
    09:57:10,411 INFO [WsdlProject] Loaded project from [file:/C:/Eclipse64/workspace/soapui-test/src/test/resources/timeservice-soapui-project.xml]
    09:57:10,419 INFO [SoapUITestCaseRunner] Setting project property [pmessage] to [Hello Project!]
    09:57:10,421 INFO [SoapUITestCaseRunner] Running soapUI tests in project [timeservice]
    09:57:10,421 INFO [SoapUITestCaseRunner] Running TestCase [RequestTime TestCase]
    09:57:10,429 INFO [SoapUITestCaseRunner] Running soapUI testcase [RequestTime TestCase]
    09:57:10,489 INFO [SoapUITestCaseRunner] running step [RequestTime]
    09:57:10,840 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
    09:57:10,840 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /mockTimeServiceSOAP HTTP/1.1
    09:57:10,885 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
    09:57:10,888 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
    09:57:11,005 INFO [SoapUITestCaseRunner] Assertion [SOAP Response] has status FAILED
    09:57:11,006 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> error: </p> does not close tag <body>.
    09:57:11,006 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> </p> does not close tag <body>.
    09:57:11,006 INFO [SoapUITestCaseRunner] Assertion [Contains] has status FAILED
    09:57:11,006 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> Missing token [16:25] in Response
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    As mentioned earlier, no hands on maven.
    The post given in the previous reponse worked for the community member.
    I believe, if pom.xml is defined correctly it is normally be not an issue.

    In windows, some times it asks for confirmation with a dialog popup "block", "unblock" when certain programs are invoked. Seems similar thing you are facing.

    In the pom.xml, it was given as below for mock(reference link)
           
    <execution>
    <id>StartupMock</id>
    <configuration>
    <projectFile>src/test/soapui/MyMock-soapui-project.xml</projectFile>
    <outputFolder>${project.build.directory}/surefire-reports</outputFolder>
    <junitReport>true</junitReport>
    <host>http://127.0.0.1:8181</host>
    <mockService>DataProviderMock</mockService>
    <noBlock>true</noBlock>
    </configuration>
    <goals>
    <goal>mock</goal>
    </goals>
    <phase>process-test-classes</phase>
    </execution>


    Just a wild guess, <noBlock>true</noBlock> would be the key. Hoping that you might have the similar goal defined. Please check what you have in your pom.xml.
    If you still face any issue, it would be good to attach pom.xml or relevant code snippet of it.
  • Thank you nmrao ! That was it. All I needed was <noBlock>true</noBlock>

    I'll check my code into the above mentioned GitHub url if anyone wants to use it as a template.

    Thanks again. Now I am off to the races.
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    Yes the noBlock option is very badly documented whereas it is very important

    * set it to true when you need to setup a mock services that is later used by the maven build. For instance, you want to run integration test of your project against the mock services. In this case, the mock is stopped when the maven build stops
    * set it to false if you want to let maven start the mock but you send request from outside the maven build. Then, to stop it, you press any key. Use case: can be interesting as you do not need to install soapui in the machine which run the mock, maven do it for you

    If this is not clear, ammend my explanation or ask for further information.
    If it is good, I will update the plugin documentation I maintain: https://github.com/redfish4ktc/maven-so ... #wiki-mock