blob: f81a23e385caaeb1fbd198f4dffb631ca3f19ae8 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia at 2015-07-03
| Rendered using Apache Maven Fluido Skin 1.3.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20150703" />
<meta http-equiv="Content-Language" content="en" />
<title>axis-server-maven-plugin &#x2013; Usage</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<div id="bannerLeft">
<h2>axis-server-maven-plugin</h2>
</div>
</div>
<div class="pull-right"> <a href="../.." id="bannerRight">
<img src="../../images/axis-small.png" alt="Apache Axis"/>
</a>
</div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li class="">
<a href="http://www.apache.org/" class="externalLink" title="Apache">
Apache</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../../../" title="Axis">
Axis</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../../" title="Axis 1.x">
Axis 1.x</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../" title="Java">
Java</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../" title="Maven plugins">
Maven plugins</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="./" title="axis-server-maven-plugin">
axis-server-maven-plugin</a>
</li>
<li class="divider ">/</li>
<li class="">Usage</li>
<li id="publishDate" class="pull-right">Last Published: 2015-07-03</li> <li class="divider pull-right">|</li>
<li id="projectVersion" class="pull-right">Version: 1.4.1-SNAPSHOT</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li>
<a href="index.html" title="Introduction">
<i class="none"></i>
Introduction</a>
</li>
<li>
<a href="plugin-info.html" title="Goals">
<i class="none"></i>
Goals</a>
</li>
<li class="active">
<a href="#"><i class="none"></i>Usage</a>
</li>
<li class="nav-header">Apache</li>
<li>
<a href="http://www.apache.org/licenses/LICENSE-2.0.html" class="externalLink" title="License">
<i class="none"></i>
License</a>
</li>
<li>
<a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship">
<i class="none"></i>
Sponsorship</a>
</li>
<li>
<a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
<i class="none"></i>
Thanks</a>
</li>
<li>
<a href="http://www.apache.org/security/" class="externalLink" title="Security">
<i class="none"></i>
Security</a>
</li>
</ul>
<form id="search-form" action="http://www.google.com/search" method="get" >
<input value="ws.apache.org/axis/java" name="sitesearch" type="hidden"/>
<input class="search-query" name="q" id="query" type="text" />
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=search-form"></script>
<hr class="divider" />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span9" >
<!-- Licensed to the Apache Software Foundation (ASF) under one --><!-- or more contributor license agreements. See the NOTICE file --><!-- distributed with this work for additional information --><!-- regarding copyright ownership. The ASF licenses this file --><!-- to you under the Apache License, Version 2.0 (the --><!-- "License"); you may not use this file except in compliance --><!-- with the License. You may obtain a copy of the License at --><!-- --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!-- --><!-- Unless required by applicable law or agreed to in writing, --><!-- software distributed under the License is distributed on an --><!-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --><!-- KIND, either express or implied. See the License for the --><!-- specific language governing permissions and limitations --><!-- under the License. --><div class="section">
<h2><a name="Usage"></a>Usage</h2>
<div class="section">
<h3><a name="Automating_tests_that_require_a_running_Axis_server_instance"></a>Automating tests that require a running Axis server instance</h3>
<p>Test that require a running Axis server instance should be executed in the <tt>integration-test</tt> phase instead of the <tt>test</tt> phase. That means that you need to configure an execution of the <a class="externalLink" href="http://maven.apache.org/plugins/maven-failsafe-plugin">maven-failsafe-plugin</a> (we'll see that later) and prevent the <a class="externalLink" href="http://maven.apache.org/plugins/maven-surefire-plugin">maven-surefire-plugin</a> from executing these tests in the <tt>test</tt> phase. There are several ways this can be done. One is to follow the naming convention recommended by the maven-failsafe-plugin, i.e. to ensure that all integration test cases match one of the following patterns: <tt>IT*.java</tt>, <tt>*IT.java</tt> or <tt>*ITCase.java</tt>. The other option is to completely skip the execution of the maven-surefire-plugin plugin. To do this, add the following configuration to your POM:</p>
<div>
<pre> &lt;plugin&gt;
&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;default-test&lt;/id&gt;
&lt;configuration&gt;
&lt;skip&gt;true&lt;/skip&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre></div>
<p>The Axis server needs to listen on a TCP port to receive HTTP requests. When using a continuous integration tool, it is important to ensure that builds (of different projects or different branches of the same project) can be executed concurrently on the same host without interfering with each other. That implies that one should avoid hard coded port numbers and instead allocate ports dynamically during the build. The <tt>reserve-network-port</tt> goal of the <a class="externalLink" href="http://mojo.codehaus.org/build-helper-maven-plugin/">build-helper-maven-plugin</a> provides the necessary feature to achieve this:</p>
<div>
<pre> &lt;plugin&gt;
&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
&lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;reserve-network-port&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;reserve-network-port&lt;/goal&gt;
&lt;/goals&gt;
&lt;phase&gt;pre-integration-test&lt;/phase&gt;
&lt;configuration&gt;
&lt;portNames&gt;
&lt;portName&gt;axisServerPort&lt;/portName&gt;
&lt;/portNames&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre></div>
<p>This execution will allocate a TCP port and store the port number in the <tt>axisServerPort</tt> property for later use. We are now ready to configure the Axis server instance:</p>
<div>
<pre> &lt;plugin&gt;
&lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
&lt;artifactId&gt;axis-server-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;1.4.1-SNAPSHOT&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;start-server&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;start-server&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;port&gt;${axisServerPort}&lt;/port&gt;
&lt;wsdds&gt;
&lt;wsdd&gt;
&lt;directory&gt;/Users/veithen/projects/axis/maven/axis-server-maven-plugin/target/wsdd&lt;/directory&gt;
&lt;/wsdd&gt;
&lt;/wsdds&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;execution&gt;
&lt;id&gt;stop-server&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;stop-all&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre></div>
<p>Note the reference to the <tt>axisServerPort</tt> property set by the build-helper-maven-plugin. Also note the <tt>wsdds</tt> option that specifies the location of the WSDD files for the Web services to deploy. These files are typically generated using the <a href="../wsdl2java/index.html">wsdl2java-maven-plugin</a>.</p>
<p>The axis-server-maven-plugin assumes that <tt>org.apache.axis.server.standalone.StandaloneAxisServer</tt> class (not to be confused with the old <tt>org.apache.axis.transport.http.SimpleAxisServer</tt> class) is in the class path. Therefore, you need to add the relevant dependency to your project:</p>
<div>
<pre> &lt;dependency&gt;
&lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
&lt;artifactId&gt;axis-standalone-server&lt;/artifactId&gt;
&lt;version&gt;1.4.1-SNAPSHOT&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;</pre></div>
<p>Obviously the integration tests also need to know the port number of the Axis server. The easiest way is to provide that information using a system property, as shown in the following sample configuration for the maven-failsafe-plugin:</p>
<div>
<pre> &lt;plugin&gt;
&lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;goals&gt;
&lt;goal&gt;integration-test&lt;/goal&gt;
&lt;goal&gt;verify&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;includes&gt;
&lt;include&gt;**/*Test.java&lt;/include&gt;
&lt;/includes&gt;
&lt;systemPropertyVariables&gt;
&lt;axisServerPort&gt;${axisServerPort}&lt;/axisServerPort&gt;
&lt;/systemPropertyVariables&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre></div></div>
<div class="section">
<h3><a name="Running_integration_tests_manually_in_an_IDE"></a>Running integration tests manually in an IDE</h3>
<p>The approach described in the previous section is designed to automatically execute integration tests during the Maven build. However, from time to time you may want to execute some of these tests manually in your favorite IDE, for debugging purposes or to develop new test cases. With most modern IDEs, running a test case is easy; the tricky part is to start the Axis server instance with which these test cases will interact. Obviously you could set up the Axis server manually, but this is time consuming and doesn't allow you to leverage all the effort you put into setting up your Maven project. Instead it would be much simpler if you could just run the Maven build and suspend the execution of the build after the execution of the <tt>start-server</tt> goal. This would give you a fully configured Axis server instance that you can use to execute the test cases from within your IDE.</p>
<p>This use case is supported by the <tt>start-server</tt> goal. Simply set the <tt>axis.server.foreground</tt> property on the command line:</p>
<div>
<pre>mvn clean integration-test -Daxis.server.foreground=true</pre></div>
<p>If you configured your Maven project following the best practices described in the previous section, then this will still start the Axis server on a dynamically allocated port. This is undesirable because you would have to configure your IDE to pass the relevant system property (<tt>axisServerPort</tt> in the sample configuration) to your test cases, and in addition you would have to constantly update that configuration because the port number changes every time you restart the Axis server. You have two options to avoid this. One is to override the port number on the command line:</p>
<div>
<pre>mvn clean integration-test -Daxis.server.foreground=true -DaxisServerPort=8080</pre></div>
<p>The other option is to add a <tt>foregroundPort</tt> property with the port number to the configuration of the <tt>start-server</tt> goal:</p>
<div>
<pre> &lt;plugin&gt;
&lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
&lt;artifactId&gt;axis-server-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;1.4.1-SNAPSHOT&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;start-server&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;start-server&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;port&gt;${axisServerPort}&lt;/port&gt;
&lt;foregroundPort&gt;8080&lt;/foregroundPort&gt;
...
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;execution&gt;
&lt;id&gt;stop-server&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;stop-all&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre></div>
<p>If you now run the <tt>start-server</tt> goal in foreground mode, it will automatically choose the alternate port number you have specified.</p>
<p>In addition to that configuration you should also write your integration test cases such that they fall back to the specified port number if the relevant system property is not set. For the sample configuration used here, that means that to determine the port number, the following code should be used:</p>
<div>
<pre>System.getProperty(&quot;axisServerPort&quot;, &quot;8080&quot;)</pre></div>
<p>If you set up your project like that, then no additional configuration is required in your IDE and you only need to pass the <tt>axis.server.foreground</tt> property to Maven.</p></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row span12">Copyright &copy; 2000-2015
<a href="http://www.apache.org/">The Apache Software Foundation</a>.
All Rights Reserved.
</div>
</div>
</footer>
</body>
</html>