我创建了一个新项目,它只会运行集成测试
- maven-ear-插件
- maven-failsafe-插件
- maven 嵌入式 glassfish 插件
当我将包装设置为 ear 时,ear 文件被创建,glassfish 运行但测试被忽略,我收到以下消息
[failsafe:integration-test] 没有要运行的测试。
并且 glassfish 取消部署失败
[嵌入式玻璃鱼:取消部署]
2012 年 8 月 17 日上午 10:08:17 PluginUtil doUndeploy
信息:部署者 = com.sun.enterprise.admin.cli.embeddable.DeployerImpl@105f0f87 2012 年
8 月 17 日上午 10:08:17 com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream
报告
警告:输入流已被最终确定或强制关闭,但未明确
关闭; 在 com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream的以下堆栈跟踪
java.lang.Throwable 中报告了流实例化。(ASURLClassLoader.java:1230)
当我将包装设置为罐子时,我得到
运行 packageName.MyServiceTest
17/08/2012 10:09:34 AM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl
findDerbyClient 信息:找不到 javadb 客户端 jar 文件,derby jdbc 驱动程序默认
不可用。org.omg.CORBA.COMM_FAILURE:FINE:IOP00410001:连接失败:socketType:IIOP_CLEAR_TEXT;主机名:本地主机;端口:3700 vmcid:OMG 次要代码:1 已完成: 在 sun.reflect.GeneratedConstructorAccessor27.newInstance 处没有(未知来源)
并且 glassfish 没有启动
我知道它与 Maven 生命周期有关,它不允许我创建 ear 文件、启动 glassfish 嵌入式服务器并在同一个项目中运行集成测试。
有人可以建议我一个解决方案吗?我正在尝试仅使用 EJB 和业务实体项目创建 ear 文件并将其部署到嵌入式 glassfish 服务器以使用 maven-failsafe-plugin 运行集成测试,而不是部署由父 pom.xml 创建的 ear 文件,它添加UI等项目放入ear文件。
这是我的 pom.xml 文件
http://maven.apache.org/xsd/maven-4.0.0.xsd">4.0.0
<parent>
<groupId>company.MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>3.8.1-SNAPSHOT</version>
</parent>
<artifactId>MyProject-integration-test</artifactId>
<packaging>jar</packaging>
<name>MyProject Integration Tests</name>
<properties>
<ear-final-name>MyProject-integration-test-${project.version}</ear-final-name>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion</artifactId>
<version>1.4.2</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion-extensions</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>MyProject-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words-jdk15</artifactId>
<version>${aspose.libraryVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>hibernate-entitymanager</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>hibernate-annotations</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>hibernate-commons-annotations</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.1.0.5.0</version>
</dependency>
<dependency>
<groupId>ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org-apache-commons-logging</groupId>
<artifactId>org-apache-commons-logging</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
<configuration>
<version>5</version>
<displayName>MyProject</displayName>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<finalName>${ear-final-name}</finalName>
<name>MyProject-integration-test</name>
<modules>
<ejbModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-ejb</artifactId>
<bundleFileName>MyProject-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-business-entities</artifactId>
<bundleFileName>MyProject-business-entities-3.8.1-SNAPSHOT.jar</bundleFileName>
</jarModule>
<jarModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-util</artifactId>
<bundleFileName>MyProject-util-3.8.1-SNAPSHOT.jar</bundleFileName>
</jarModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>failsafe-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<autoDelete>true</autoDelete>
<app>${basedir}/target/MyProject-integration-test-${project.version}.ear</app>
<port>8080</port>
<configFile>src/test/resources/glassfish/config/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>
</plugins>
</build>