Integration testing maven嵌入式glassfish插件部署2个应用程序
我有以下用例: 我正在使用SpringWS实现的web服务使用SpringMVC实现一个web应用程序 这些项目使用maven作为构建工具。 现在我想为web应用程序实现集成测试。 为此,我想使用maven嵌入式glassfish插件。 我在pom.xml中有以下maven配置:Integration testing maven嵌入式glassfish插件部署2个应用程序,integration-testing,glassfish-3,web-deployment,Integration Testing,Glassfish 3,Web Deployment,我有以下用例: 我正在使用SpringWS实现的web服务使用SpringMVC实现一个web应用程序 这些项目使用maven作为构建工具。 现在我想为web应用程序实现集成测试。 为此,我想使用maven嵌入式glassfish插件。 我在pom.xml中有以下maven配置: <plugin> <groupId>org.glassfish</groupId> <artifactId>maven-embedded-glas
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>${basedir}/target/web-app.war</app>
<autoDelete>true</autoDelete>
<port>8080</port>
<name>web-app</name>
<configFile>src/test/resources/glassfish/domain.xml</configFile>
</configuration>
<executions>
<execution>
<id>start-glassfish</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>glassfish-deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>glassfish-undeploy</id>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
</goals>
</execution>
<execution>
<id>stop-glassfish</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
玻璃鱼
maven嵌入式glassfish插件
3.1.1
嵌入式玻璃鱼
${basedir}/target/web-app.war
真的
8080
网络应用
src/test/resources/glassfish/domain.xml
启动玻璃鱼
预集成测试
开始
玻璃鱼
预集成测试
部署
玻璃鱼解除部署
整合后测试
解除部署
阻止玻璃鱼
整合后测试
停止
一切正常。
但是现在我需要添加webservice.war文件的部署。
这不是我的pom在这一刻的依赖。
我只有一个存根类用于调用web-app.war应用程序中定义的web服务
那么,如何部署第二个应用程序,有什么好的解决方案吗
我希望自动成为某种东西,可能使用maven存储库,因为如果我进行了修改,我希望自动使用新版本的web服务。我在users@embedded-glassfish.java.net和Bhavani Shankar先生提供了以下解决方案:
<execution>
<id>glassfish-additional_deployments</id>
<phase>pre-integration-test</phase>
<goals>
<goal>admin</goal>
</goals>
<configuration>
<commands>
<param>deploy ${basedir}/src/test/resources/integrationtest/app-ws.war</param>
</commands>
</configuration>
</execution>
glassfish-U额外部署
预集成测试
管理
部署${basedir}/src/test/resources/integrationtest/app-ws.war
实际上,您可以在war的maven中设置依赖项,然后从lib目录部署war文件
如果有人想使用此选项,则此插件有一些有趣的地方:
<instanceRoot>${project.build.directory}/glassfish</instanceRoot>
${project.build.directory}/glassfish
仅在现有glassfish安装的3.1.1版中不起作用。
如果要设置此属性,请使用(无需安装glassfish):
glassfish.embedded.tmpdir=target/glassfish
对于maven embedded glassfish插件的3.1.1版本,您只需将“glassfish.embedded.tmpdir”属性设置为静态值(对于windows操作系统,但对于linux,我不确定)。因为maven无法转换路径
我正在给玻璃鱼装一只耳朵,它对我非常有效
我的配置是:
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<systemProperties>
<property>glassfish.embedded.tmpdir=target/glassfish</property>
</systemProperties>
<app>${project.build.directory}/${build.finalName}.ear</app>
<autoDelete>true</autoDelete>
<port>8080</port>
<contextRoot>test</contextRoot>
</configuration>
<executions>
<execution>
<id>start-glassfish</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
玻璃鱼
maven嵌入式glassfish插件
3.1.1
glassfish.embedded.tmpdir=target/glassfish
${project.build.directory}/${build.finalName}.ear
真的
8080
测试
启动玻璃鱼
安装
跑
但是如果我删除glassfish.embedded.tmpdir=target/glassfish
部分,然后启动服务器,它加载项目的速度很慢,而且不稳定
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<systemProperties>
<property>glassfish.embedded.tmpdir=target/glassfish</property>
</systemProperties>
<app>${project.build.directory}/${build.finalName}.ear</app>
<autoDelete>true</autoDelete>
<port>8080</port>
<contextRoot>test</contextRoot>
</configuration>
<executions>
<execution>
<id>start-glassfish</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>