使用arquillian玻璃鱼容器

时间:2011-12-09 09:50:08

标签: jboss-arquillian

我曾经使用以下maven依赖项来使用arquillian glassfish容器:

 <dependency> 
     <groupId>org.jboss.arquillian</groupId>
     <artifactId>arquillian-junit</artifactId> 
 <scope>test</scope>
     <version>1.0.0.Alpha5</version>
 </dependency>  
 <dependency> 
     <groupId>org.jboss.arquillian.container</groupId> 
 <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
     <version>1.0.0.Alpha5</version>
 </dependency> 

我能够成功运行我的测试,直到我想注入无法通过JNDI查找的特定资源。

我改进了我的domain.xml以获得我想要的相关资源。但是现在,我不确定arquillian是否成功加载了所有的domain.xml(在“jca / Neo4j / resource”上查找失败)。

我的arquillian.xml(在src / test / resources中):

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.com/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
    <glassfish:container>
        <glassfish:instanceRoot>src/test/resources/glassfish</glassfish:instanceRoot>
        <glassfish:bindPort>9090</glassfish:bindPort>
        <glassfish:autoDelete>false</glassfish:autoDelete>
    </glassfish:container>

我的domain.xml(在src / test / resources / glassfish / config /中):

<domain log-root="${com.sun.aas.instanceRoot}/logs" applicationroot="${com.sun.aas.instanceRoot}/applications" version="10.0">
    <resources>
        <connector-connection-pool name="jca/Neo4j/pool" resource-adapter-name="neo4j-connector-0.1-SNAPSHOT" connection-definition-name="com.netoprise.neo4j.connection.Neo4JConnectionFactory">
            <property name="dir" value="${com.sun.aas.instanceRoot}/lib/databases/neo4j"></property>
            <property name="xa" value="true"></property>
        </connector-connection-pool>
        <connector-resource pool-name="jca/Neo4j/pool" jndi-name="jca/Neo4j/resource"></connector-resource>
    </resources>
    <servers>
        <server name="server" config-ref="server-config">
            <application-ref ref="neo4j-connector-0.1-SNAPSHOT" virtual-servers="server"></application-ref>
            <resource-ref ref="jca/Neo4j/resource"></resource-ref>
        </server>
    </servers>
...
</domain>

谢谢, 亚历

1 个答案:

答案 0 :(得分:0)

Alpha5有点难以处理:) 东西改变了一点,如果你想尝试最新的1.0.0.Final-SNAPSHOT,你可以在这里更详细地看一下配置: http://blog.eisele.net/2012/01/arquillian-with-netbeans-glassfish.html

谢谢, 中号