We have a set of soapui tests that are being run via a maven project using the soapui maven plugin which is run by a Jenkins job as well.
As we have various environments we pass a "host" parameter via the environment, from Jenkins to the Maven build.
There is a <host>${HOST}</host> element that allows us to configure the host. The problem is that the maven plugin seems to dislike when adding the protocol prefix inside the parameter value:
<host>example.com</host> Will work
<host>https://example.com</host> Won't work (java.net.UnknownHostException: https)
So if I am not allowed to provide the protocol prefix, then I don't know how to tell the maven soapui plugin that the host is using ssl.
Here is the configuration in the pom.xml that we are using:
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>5.0.0</version>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<configuration>
<projectFile>${project.build.directory}/test-classes/my-soapui-project.xml</projectFile>
<host>${HOST}</host>
<junitReport>true</junitReport>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui-logs/</value>
</property>
</soapuiProperties>
<outputFolder>${project.build.directory}/soapui-output</outputFolder>
</configuration>
<executions>
<execution>
<id>first-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testSuite>first-TestSuite</testSuite>
</configuration>
</execution>
<execution>
<id>second-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testSuite>second-TestSuite</testSuite>
</configuration>
</execution>
</executions>
</plugin>
...
Edited: Based in the answer by Bistro:
Instead of using <host>${HOST}</host> I now use <endpoint>${HOST}</endpoint> it does the trick.
Can you try adding an <endpoint> parameter. Someone in the SoapUI forum had a similar issue, but was able to resolve the connection issue by adding this parameter. He does mention that it causes another issue. But it's worth a shot. Here is the post link
I have the following setup: normally my webapp will be deployed on stand-alone server and connect to MySQL database. However I want ability to "self-test" the application with Selenium. So during mvn clean install there will be embedded server (Jetty 7), Selenium Server and in-memory database (HSQLDB) that will allow to perform some actions (example user inputs for the webapp).
Now I already setup Selenium/embedded server setup using maven plugins:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<!-- Log to the console. -->
<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
<!-- This doesn't do anything for Jetty, but is a workaround for a Maven bug
that prevents the requestLog from being set. -->
<append>true</append>
</requestLog>
</configuration>
</plugin>
<!--
*******************************************************
Start selenium-server before the integration test start
*******************************************************
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<executions>
<execution>
<id>start-selenium-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
<multiWindow>true</multiWindow>
</configuration>
</execution>
<execution>
<id>stop-selenium-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ********************************************************
Force to run the testcases in the integration-test phase
******************************************************** -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<!-- ***********************************************************
Deploy the war in the embedded jetty of cargo2-maven-plugin
*********************************************************** -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.1-SNAPSHOT</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<wait>false</wait>
<container>
<containerId>jetty7x</containerId>
<type>embedded</type>
</container>
</configuration>
</plugin>
And it is working just fine. Unfortunately I'm having some issues trying to make Spring/Maven use different XML configuration file when app is being deployed on embedded server for integration testing purposes.
I tried using:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = { "classpath:servlet-context-test.xml" })
#FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestWebapp extends SeleneseTestCase{
(servlet-context-text.xml is located in src/test/resources)
but when Selenium tests run the webapp is still started with default configuration.
I'm trying to load different xml file because I basically want to use this:
<jdbc:embedded-database id="dataSource">
<jdbc:script location="classpath:sql/schema.sql"/>
<jdbc:script location="classpath:sql/fk.sql"/>
<jdbc:script location="classpath:sql/data.sql"/>
</jdbc:embedded-database>
instead of my normal dataSource declaration.
You should have a look at the Spring profiles (http://blog.springsource.org/2011/02/14/spring-3-1-m1-introducing-profile/). With a profile, you can activate/deactivate beans in different ways (programamtically, with environment variable etc.)
Maybe it will be helpful to someone out there. I finally resolved this issue using Maven profiles (separate profiles for integration testing and for production build) and filtering (parametrized my servlet-context.xml in regards to importing either dataSource.xml or dataSourceIntegrationTesting.xml). Works like a charm.
I have a root pom configured with the maven-surefire-plugin and a gwt module pom configured with the gwt-maven-plugin.
After upgrading to Maven 3 I get strange errors.
The project is similar configured like described here: Separate GwtTest tests from standard unit tests
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<useSystemClassLoader>true</useSystemClassLoader>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<argLine>-server -Xmx8192m -XX:MaxPermSize=1024M -XX:+CMSClassUnloadingEnabled</argLine>
<excludes>
<exclude>**/*GwtTest*.java</exclude>
</excludes>
</configuration>
</plugin>
AND
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<configuration>
<modules>
<module>my.app.gwt</module>
</modules>
<runTarget>/</runTarget>
<extraJvmArgs>-Xss512m -Xmx2048m -XX:MaxPermSize=256M</extraJvmArgs>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
<includes>**/*GwtTestSuite.java</includes>
<copyWebapp>true</copyWebapp>
<logLevel>INFO</logLevel>
<persistentunitcache>false</persistentunitcache>
<draftCompile>${gwt.draftCompile}</draftCompile>
<deploy>${project.build.directory}/${project.build.finalName}/WEB-INF/deploy</deploy>
<disableCastChecking>true</disableCastChecking>
<mode>htmlunit</mode>
<skipTests>${skipGwtTests}</skipTests></configuration>
<executions>
<execution>
<id>gwt-compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>gwt-test</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
It works with maven 2 but with maven 3 I get :
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0:test (gwt-test) on project my-webapp: Unable to parse configuration of mojo org.codehaus.mojo:gwt-maven-plugin:2.5.0:test: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'excludes'. -> [Help 1]
It seems that the gwt plugin can't parse the hierarchical style of the surefire plugin.
It only compiles if I set all excludes/includes inside the gwt plugin as one comma separated string line, but that doesn't work for me, because I need to exclude the gwt tests globally, and include them locally.
The include/exclude sections get merged however, so that the two incompatible syntax definitions won't work together.
I hope somebody can give me a hint.
You can run your GWTTestCases using straight Maven Surefire, see this link.
Since I'm trying to set an embded container in my maven project I want to it run during the integration test phase. I have two problems with jetty that I can not manage to resolve :
<daemon>true</daemon> doesn't have the expected effect. The server is run but then it locks the build process (in fact it blocks the unit tests). So where am I supposed to place that configuration ?
The <useTestClasspath>true</useTestClasspath> is a mystery for me. I don't want to use the src/main/webapp/WEB-INF/lib to place the postgresql jar (which is called by jetty for the datasource (postegresql-driver)) because it would be embeded in the application and I don't want it to be in the war (client side). So I want to use <useTestClasspath>true</useTestClasspath> but when I place postgresql in the src/test/resources it doesn't find/recognize it. So, how am I supposed to use that property ?
Here is the complete plugin configuration :
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.9</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
<configuration>
<useTestClasspath>true</useTestClasspath>
<daemon>true</daemon>
<contextPath>agepro-prototype</contextPath>
<webApp>
${project.build.directory}/agepro-prototype.war
</webApp>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>9091</port>
</connector>
</connectors>
<stopPort>9092</stopPort>
<stopKey>test</stopKey>
</configuration>
</plugin>
Thanks in advance for the help you could provide me. I must apologize for my grammar, because my english is quite bad.
Regards,
Depado
Not sure about your first question, but as for your second, specify the postgresql jar as provided scope in your main dependency block (this will prevent it from being bundled in the war), and add an additional dependency block in the jetty plugin definition (with compile scope), which will make the postgresql jar available at jetty runtime:
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.9</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
<configuration>
<daemon>true</daemon>
<contextPath>agepro-prototype</contextPath>
<webApp>
${project.build.directory}/agepro-prototype.war
</webApp>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>9091</port>
</connector>
</connectors>
<stopPort>9092</stopPort>
<stopKey>test</stopKey>
</configuration>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
<scope>provided</scope>
</dependency>
</dependencies>
I don't want to use the src/main/webapp/WEB-INF/lib to place the postgresql jar (which is called by jetty for the datasource (postegresql-driver)) because it would be embeded in the application and I don't want it to be in the war (client side). So I want to use true but when I place postgresql in the src/test/resources it doesn't find/recognize it
You shouldn't be placing jars in any folders (src/main/resources or src/main/webapp/WEB-INF/classes), they should all be defined as dependencies in your pom.
I also imagine the useTestClasspath is being ignored when you define the webApp configuration element, as the it's using the packaged war, which will not contain your test resources / classes
useTestClasspath/useTestScope are only available for jetty:run
This is why it doesn't work with jetty:run-war and other jetty:goals
Suppose I want to create and use an H2 database for my integration tests.
Maven has a command to run tests: mvn test.
Is there a way to tell maven to start an H2 database server for the tests and stop it when it's done?
I imagine this working similar to how I can run tomcat via a Maven command (mvn tomcat:run).
Sorry if this question is nonsensical, I'm still wrapping my head around new concepts.
I was able to get it to work without using an external server just by adding the dependency to H2 via Maven and then using this bean:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver"/>
<property name="url" value="jdbc:h2:file:h2\db"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
Then again, this required that I use a file-based DB instead of in-memory. But it does the trick.
you can create 2 small classes with main methods that start and stop the database. the idea is to run the StartServer class before the integration tests are run and then class StopServer after the tests have run.
you should do the same for your DB server as described somewhere in this document (description is for starting and stopping Jetty in integration tests)
in your pom.xml you should define the maven-exec-plugin to run the exec:java goal and create 2 executions (1 for calling StartServer and 1 for StopServer):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<!-- start server before integration tests -->
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.foo.StartServer</mainClass>
</configuration>
</execution>
<execution>
<!-- stop server after integration tests -->
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.foo.StopServer</mainClass>
</configuration>
</execution>
</executions>
</plugin>
hope that's what you want
This plugin works fine to spawn a new H2 DB with tcp mode before integration tests (the default plugin phase): h2-maven-plugin on github
It is not well documented but you can check the Mojo sources to know the configuration options. It is published on maven central.
Basically, for integration tests, you may want Maven to:
Reserve randomly available network ports, for your Tomcat server, and your H2 (to avoid port conflicts)
Start the H2 server
Start the Tomcat server
Run integration tests
Stop the Tomcat server
Stop the H2 server
This can be achieved with a Maven configuration looking like this.
Assuming your integration tests are annoted with a custom interface JUnit Category:
#Category(IntegrationTest.class)
This Maven configuration works fine for me:
<profile>
<id>it</id>
<build>
<plugins>
<!-- Reserve randomly available network ports -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>tomcat.test.http.port</portName>
<portName>h2.test.tcp.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<!-- Start H2 before integration tests, accepting tcp connections on the randomly selected port -->
<plugin>
<groupId>com.edugility</groupId>
<artifactId>h2-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<port>${h2.test.tcp.port}</port>
</configuration>
<executions>
<execution>
<id>Spawn a new H2 TCP server</id>
<goals>
<goal>spawn</goal>
</goals>
</execution>
<execution>
<id>Stop a spawned H2 TCP server</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Start Tomcat before integration tests on the -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<systemProperties>
<spring.profiles.active>integration_tests</spring.profiles.active>
<httpPort>${http.test.http.port}</httpPort>
<h2Port>${h2.test.tcp.port}</h2Port>
</systemProperties>
<port>${http.test.http.port}</port>
<contextFile>src/main/java/META-INF/tomcat/webapp-test-context-using-h2.xml</contextFile>
<fork>true</fork>
</configuration>
<executions>
<execution>
<id>run-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Run the integration tests annotated with #Category(IntegrationTest.class) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<!-- Bug in 2.12.x -->
<version>2.11</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
<configuration>
<groups>com.mycompany.junit.IntegrationTest</groups>
<failIfNoTests>false</failIfNoTests>
<junitArtifactName>junit:junit-dep</junitArtifactName>
<systemPropertyVariables>
<httpPort>${tomcat.test.http.port}</httpPort>
<h2Port>${h2.test.tcp.port}</h2Port>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
You may want to use maven filters on the tomcat context file so that the port is replaced:
<contextFile>src/main/java/META-INF/tomcat/webapp-test-context-using-h2.xml</contextFile>
With the file content being:
<Resource name="jdbc/dataSource"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username=""
password=""
driverClassName="org.h2.Driver"
url="jdbc:h2:tcp://localhost:${h2.test.tcp.port}/mem:db;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL"/>
Or if you don't want a JNDI datasource, you can use a Spring declared dataSource, using the the same property...
One extra trip if you want to be able to setup your integration tests tomcat, and run the integration tests from your IDE:
You can use use a property to fork or not the Tomcat server:
<fork>${integrationTestsForkTomcatJvm}</fork>
When you set fork=false, the server will block and maven won't continue, so the integration tests won't be run, but you will be able to run them from your ide.
I create a file-based H2 database before unit tests are run. The file lives in the target directory and can be removed at any time using mvn clean.
I use the maven-sql-plugin as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.166</version>
</dependency>
</dependencies>
<configuration>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:target/db/testdb</url>
<username>sa</username>
<password></password>
<autocommit>true</autocommit>
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>create-db</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<srcFiles>
<srcFile>${sql.dir}/drop_db.sql</srcFile>
<srcFile>${sql.dir}/tables.sql</srcFile>
<srcFile>${sql.dir}/constraints.sql</srcFile>
... etc ...
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
The database can be created by running mvn process-test-resources. When tests are run, make sure you connect to the database in target/db/testdb via hibernate properties.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="org.h2.Driver"
p:url="jdbc:h2:file:target/db/testdb"
p:username="sa"
p:password="" />
You will also need to a dependency on com.h2database.h2 in maven's dependencies.
In my project, for unit testing, I asked Spring to handle this database creation and initialization. As stated in the H2 documentation, you can create a bean for that:
<bean id = "org.h2.tools.Server"
class="org.h2.tools.Server"
factory-method="createTcpServer"
init-method="start"
destroy-method="stop">
<constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" />
</bean>
You simply need to start the Spring context with this configuration when you start your unit tests.
I've just started project for H2 plugin for maven # bitbucket. I will appreciate any help with it.
https://bitbucket.org/dohque/maven-h2-plugin
Hope it will be helpful.
If you want to make it in memory, then just use a different URL:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver"/>
<property name="url" value="jdbc:h2:mem:db"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
You can give additional options, such as: ;DB_CLOSE_DELAY=-1
see: http://www.h2database.com/html/features.html#in_memory_databases
following does the job for me (just using h2 dependency and the exec-maven-plugin):
<build>
<plugins>
<!-- start/stop H2 DB as a server -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>start-h2</id>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.h2.tools.Server</mainClass>
<arguments>
<argument>-tcp</argument>
<argument>-tcpDaemon</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>stop-h2</id>
<phase>post-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.h2.tools.Server</mainClass>
<arguments>
<argument>-tcpShutdown</argument>
<argument>tcp://localhost:9092</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</executableDependency>
</configuration>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.173</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
please note, in my pom.xml the com.h2database:h2 was not project dependency.
In case you'd have it you might don't need to explicitly name it as a plugin dependency.
Since H2 doesn't provide Maven plugin you should start it using maven-antrun-plugin. Write code for start and stop h2 engine in ant task and call it when your integration test starts and stop.
See details on http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing