0

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.

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
    }

}

This is my datasets/dataset.yml file:

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

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>

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
cremersstijn
  • 2,375
  • 4
  • 28
  • 41

2 Answers2

0

The problem is with your test run mode. When you define your @Deployment with the attribute testable=false, all tests are run in the client mode, i.e. they're not run in-container.

The Arquillian Persistence Extension (as of 1.0.0.Alpha5) does not support running tests in client mode; only in-container tests are supported for now. Support for client mode tests in APE may come in a future release.

Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
  • When i set testable to true, i get the a java.lang.ClassNotFoundException on PersonWebServiceIT, because the test class is not packaged in the deployment. How can I fix this? I really want to use the ear that i also use in production to make sure my integration test has the same dependencies. – cremersstijn Feb 05 '13 at 17:03
  • I have asked a new question for this problem: http://stackoverflow.com/questions/14713129/how-to-add-test-classes-to-an-imported-ear-file-and-run-server-side-with-arquill – cremersstijn Feb 05 '13 at 17:25
0
<property name="defaultDataSource">java:/DefaultDS</property>

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

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

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

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

sathya_dev
  • 513
  • 3
  • 15