arquillian glassfish容器的使用

发布于 2024-12-20 12:15:57 字数 2521 浏览 0 评论 0原文

我曾经使用以下 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>

谢谢, 亚历克斯

I used to have the following maven dependencies to use arquillian glassfish container:

 <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> 

I was able to run my tests successfully until I wanted to inject specific resources, that could not be looked up through JNDI.

I improved my domain.xml to have the relevant resources I wanted. But for now, I am not sure arquillian load successfully all the domain.xml (look up failed on "jca/Neo4j/resource").

My arquillian.xml (in 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>

My domain.xml (in 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>

Thanks,
Alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒儿 2024-12-27 12:15:57

Alpha5 有点难处理:)
内容发生了一些变化,如果您想尝试最新的 1.0.0.Final-SNAPSHOT,您可以在此处更详细地查看配置:
http://blog.eisele.net/2012/01/arquillian -with-netbeans-glassfish.html

谢谢,
中号

The Alpha5 was a bit hard to handle :)
Stuff changed a bit and if you like to give the latest 1.0.0.Final-SNAPSHOT a try, you could have a more detailed look at a configuration here:
http://blog.eisele.net/2012/01/arquillian-with-netbeans-glassfish.html

Thanks,
M

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文