Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two options, a maven solution and a surefire solution. The least coupled solution is to execute a plugin in the <code>pre-integration-test</code> and <code>post-integration-test</code> phase. See <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference" rel="noreferrer">Introduction to the Build Lifecycle - Lifecycle Reference</a>. I'm not familiar with grizzly, but here is an example using jetty:</p> <pre><code> &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt; &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;contextPath&gt;/xxx&lt;/contextPath&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;start-jetty&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;run&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;stop-jetty&lt;/id&gt; &lt;phase&gt;post-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;stop&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>Note that the phase for <code>start</code> is <code>pre-integration-test</code> and <code>stop</code> is <code>post-integration-test</code>. I'm not sure if there is a grizzly maven plugin, but you could use the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/" rel="noreferrer">maven-antrun-plugin</a> instead.</p> <p>The second option is to use a JUnit <a href="https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/runner/notification/RunListener.java" rel="noreferrer">RunListener</a>. <code>RunListener</code> listens to test events, such as test start, test end, test failure, test success etc.</p> <pre><code>public class RunListener { public void testRunStarted(Description description) throws Exception {} public void testRunFinished(Result result) throws Exception {} public void testStarted(Description description) throws Exception {} public void testFinished(Description description) throws Exception {} public void testFailure(Failure failure) throws Exception {} public void testAssumptionFailure(Failure failure) {} public void testIgnored(Description description) throws Exception {} } </code></pre> <p>So you could listen for RunStarted and RunFinished. These would start/stop the services you want. Then, in surefire, you can specify a custom listener, using:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.10&lt;/version&gt; &lt;configuration&gt; &lt;properties&gt; &lt;property&gt; &lt;name&gt;listener&lt;/name&gt; &lt;value&gt;com.mycompany.MyResultListener,com.mycompany.MyResultListener2&lt;/value&gt; &lt;/property&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>This is from <a href="http://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html#Using_custom_listeners_and_reporters" rel="noreferrer">Maven Surefire Plugin, Using JUnit, Using custom listeners and reporters</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload