Forum Discussion

ouapdouap's avatar
17 years ago

Maven integration - Mock service don't start

Hi,
I'm having a hard time making maven start my Mock Services before it executes my client's unit tests.
Here is my pom's plugin definition :

                <plugin>
                    <groupId>eviware</groupId>
                    <artifactId>maven-soapui-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <projectFile>${basedir}/vilinknotifiertool-soapui-project.xml</projectFile>
                        <settingsFile>soapui-settings.xml</settingsFile>
                    </configuration>
                    <executions>
                      <execution>
                        <id>WSMock</id>
                        <phase>test</phase>
                        <configuration>
                            <mockService>MyMockService1</mockService>
                        </configuration>
                        <goals>
                          <goal>eviware:maven-soapui-plugin:mock</goal>
                        </goals>
                      </execution>
                      <execution>
                        <id>WSMockAxeda</id>
                        <phase>test</phase>
                        <configuration>
                            <mockService>MyMockService2</mockService>
                        </configuration>
                        <goals>
                          <goal>eviware:maven-soapui-plugin:mock</goal>
                        </goals>
                      </execution>
                    </executions>
                </plugin>


Then I call a "mvn package" but my unit tests can't connect to the Web Services so I get a "Connection refused" exception.

If I start my Mock Services in another command line window using the "mvn eviware:maven-soapui-plugin:mock" command, both Mock Services start well and my unit tests run perfectly when I call "mvn package".

What do I do wrong ?
Thanks a lot for your help.
Sebastien

2 Replies

  • andersot's avatar
    andersot
    Occasional Contributor
    I'm seeing the same problem on subsequent runs of the sample demonstration project [Sample Simple Test Suite] with 3.5.1. PRO (Win 7 / IE 8 ):

    WSDL comes up fine in the browser, and mock service starts without problems

    REF: <http://uspqlnb400:8088/mockSampleServiceSoapBinding?WSDL>


    Wed Aug 04 16:11:06 CDT 2010:ERROR:java.net.ConnectException: Connection refused: connect
    java.net.ConnectException: Connection refused
    : connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at com.eviware.soapui.impl.wsdl.support.http.SoapUIMultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(SoapUIMultiThreadedHttpConnectionManager.java:1666)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:187)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:122)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:75)
    at com.eviware.soapui.impl.wsdl.WsdlRequest.submit(WsdlRequest.java:235)
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.run(WsdlTestRequestStep.java:324)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runTestStep(WsdlTestCaseRunner.java:206)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:137)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:39)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
    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)
  • It appears as the SoapUIMockServiceRunner have to be started in the phase before you need it, e.g. for integration-tests use phase pre-integration-test.

    I did like this when I wanted to use soapUI to mock Web Service responses during integrations test phase.


    <pluginRepositories>
    <pluginRepository>
    <id>eviwarePluginRepository</id>
    <url>http://www.eviware.com/repository/maven2/</url>
    </pluginRepository>
    </pluginRepositories>

    <!-- Inspiration taken from http://www.java-tutorial.ch/maven/maven-integration-test -->
    <build>
    <plugins>
    <!-- Configure the maven-surefire-plugin, i.e. unit test plugin, to exclude the integration test classes using the pattern **/*IntegrationTest.java -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.8.1</version>
    <configuration>
    <excludes>
    <exclude>**/*IntegrationTest.java</exclude>
    </excludes>
    </configuration>
    </plugin>

    <!-- Configure the maven-failsafe-plugin, i.e. the integration test plugin, to exclude the integration test classes using the pattern **/*IntegrationTest.java -->
    <plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.8.1</version>
    <configuration>
    <includes>
    <include>**/*IntegrationTest.java</include>
    </includes>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>integration-test</goal>
    <goal>verify</goal>
    </goals>
    </execution>
    </executions>
    </plugin>

    <plugin>
    <groupId>eviware</groupId>
    <artifactId>maven-soapui-plugin</artifactId>
    <version>3.6.1</version>
    <executions>
    <execution>
    <!--Run as part of the pre-integration-test phase in the Maven lifecycle-->
    <[b]phase>pre-integration-test</phase>[/b]
    <id>delegates-soapui-integration-test</id>
    <configuration>
    <projectFile>${pom.basedir}\delegates\src\test\resources\soapui\delegates-soapui-project.xml</projectFile>
    <noBlock>true</noBlock>
    </configuration>
    <goals>
    <!--Run the mock phase of eviware:maven-soapui-plugin-->
    <goal>mock</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>