2012-08-17 231 views
2

我已经创建了一个新的项目,该项目将只与运行集成测试集成测试

  • 行家入耳式插件
  • Maven的故障保护,插件
  • Maven的嵌入与GlassFish插件

当我设置的包装耳耳文件被创建,GlassFish的运行,但测试被忽略,我收到以下消息

[故障安全:集成测试]没有测试运行。

和GlassFish取消部署失败

[嵌入的glassfish:取消部署]
17/08/2012上午10点08分17秒PluginUtil doUndeploy
INFO:部署= com.sun.enterprise。 [email protected]
17/08/2012 10:08:17 AM com.sun.enterprise.loader.ASURLClassLoader $ SentinelInputStream
报告
警告:输入流已经完成或强制关闭而未明确
已关闭;在以下堆栈跟踪中报告的流实例化
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader $ SentinelInputStream。
(ASURLClassLoader.java:1230)

当我设置的包装到坛子里 我得到

运行packageName.MyServiceTest
17/08/2012上午10点09分34秒的com.sun .enterprise.v3.server.CommonClassLoaderServiceImpl
findDerbyClient
信息:无法找到javadb客户端jar文件,derby jdbc驱动程序将不会由
默认提供。
org.omg.CORBA.COMM_FAILURE:FINE:IOP00410001:连接失败:socketType:
IIOP_CLEAR_TEXT;主机名:localhost;端口:3700 vmcid:OMG次要代码:1
完成:没有
在sun.reflect.GeneratedConstructorAccessor27.newInstance(来源不明)

和GlassFish不启动

我知道它必须做一些事情Maven的生命周期不允许我创建ear文件,启动glassfish嵌入式服务器并在同一个项目中运行集成测试。

有人可以给我一个解决方案吗?我试图创建仅包含EJB和Business实体项目的ear文件,并将其部署到嵌入式glassfish服务器,以使用maven-failsafe插件运行集成测试,而不是部署由父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> 

+0

您是否测试过在命令行上构建ear并将其部署到glassfish中? – khmarbaise 2012-08-20 06:55:30

回答

1

是的,它现在工作。原来问题是我的domain.xml文件。默认的domain.xml带有前缀2的端口号,应该删除,并且在嵌入的glassfish 3.1中<端口> 8080 </port>不能工作,如果< configFile>设置了(ref this Doco) http://embedded-glassfish.java.net/nonav/plugindocs/3.1/stop-mojo.html

我不得不domain.xml中IIOP端口设置为3700,并在我的测试

Properties props = new Properties(); 
props.put("org.omg.CORBA.ORBInitialPort", "3700"); 
Context ctx = new InitialContext(props); 

谢谢你们

0

你可以做包装,并开始在单个调用了GlassFish

你尝试过:

mvn verify 

这样做?

+0

是的,我试过了。运行mvn验证产生了上述结果。我们现在要去尝试Arquillian。希望将arquillian的ear文件部署到glassfish上并运行集成测试会更容易。 – Dev2 2012-08-19 05:33:18

+0

你能告诉我怎么能得到一个由我的测试用例中的maven开始的Glassfish实例吗? – Dev2 2012-08-22 00:56:06

+0

看起来你已经配置了它。它不起作用吗? – khmarbaise 2012-08-22 05:58:08

0

可能的另一种解决方案,以指定的GlassFish IIOP端口(第一,有必要确认服务器IP和IIOP侦听器端口):

System.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1"); 
System.setProperty("org.omg.CORBA.ORBInitialPort", "8037"); 
Context ctx = new InitialContext();