Arquillian持久性扩展不起作用 [英] arquillian persistence extension doesn't work

查看:95
本文介绍了Arquillian持久性扩展不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对我的Web服务进行测试.此Web服务将ejb与jpa一起使用以检索其数据.所以我想使用arquillian扩展来完成此操作.

I'm trying to get my webservice tested. This webservice uses ejb with jpa to retrieve its data. So i want to use the arquillian extension to get this done.

这是我的Arquillian测试班:

This is my arquillian test class:

@RunWith(Arquillian.class)
public class PersonWebServiceIT {

    private PersonWebService service;

    @Deployment(testable = false)
    public static Archive<?> createDeployment() {
        return ShrinkWrap
                .create(ZipImporter.class, "test.ear")
                .importFrom(new File("simple-webservice-ear-1.0.0-SNAPSHOT.ear"))
                .as(EnterpriseArchive.class);
    }

    @Test
    @UsingDataSet("dataset.yml")
    @SneakyThrows
    public void testFindPersons(@ArquillianResource final URL deploymentUrl) {
        loadService(deploymentUrl);

        Assert.assertEquals(2, service.findPersons().size());
    }

    private void loadService(final URL deploymentUrl)
        //load webservice
    }

}

这是我的datasets/dataset.yml文件:

This is my datasets/dataset.yml file:

person:
  - id: 1
    firstName: "stijn"
  - id: 2
    firstName: "cremers"

我的arquillian.xml:

my arquillian.xml:

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.com/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian-1.0.xsd">

 <extension qualifier="persistence">
        <property name="defaultDataSource">java:/DefaultDS</property>
    </extension>

</arquillian>

我的测试数据从不加载.我什至尝试使用格式错误的yml文件,但即使这样我也没有收到任何错误.

My test data never gets loaded. I even tried with a wrongly formatted yml file, but even then i get no error.

推荐答案

<property name="defaultDataSource">java:/DefaultDS</property>

您要指定服务器中定义的数据源.

U're specifying the Datasource which is defined in the server.

在客户端模式下,测试用例在容器(即其他JVM)之外运行

In client mode, test cases are run outside the Container(ie. Other JVM)

因此仅持久性扩展不能使用数据源,因此您不能使用Arquillian持久性扩展客户端模式.

So that only persistence extension can not make use of data source and hence you can not use arquillian persistence extension client mode.

如果仍然在arquillian.xml文件中指定jdbc url而不是数据源名称.那么您可以使用持久性扩展

If there is anyway to specify jdbc url instead of datasource name in arquillian.xml file.Then u may use persistence extension

这篇关于Arquillian持久性扩展不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆